Merge branch 'tizen_base' into tizen
[platform/upstream/expat.git] / configure.ac
index 7e968c4..c24f518 100644 (file)
@@ -25,12 +25,13 @@ dnl test. I believe this test will work, but I don't have a place with non-
 dnl GNU M4 to test it right now.
 define([expat_version], ifdef([__gnu__],
                               [esyscmd(conftools/get-version.sh lib/expat.h)],
-                              [2.1.x]))
+                              [2.2.x]))
 AC_INIT(expat, expat_version, expat-bugs@libexpat.org)
 undefine([expat_version])
 
 AC_CONFIG_SRCDIR(Makefile.in)
 AC_CONFIG_AUX_DIR(conftools)
+AM_INIT_AUTOMAKE
 AC_CONFIG_MACRO_DIR([m4])
 
 
@@ -45,10 +46,11 @@ dnl
 dnl If the API changes incompatibly set LIBAGE back to 0
 dnl
 
-LIBCURRENT=7
-LIBREVISION=0
-LIBAGE=6
+LIBCURRENT=7   # sync
+LIBREVISION=7  # with
+LIBAGE=6       # CMakeLists.txt!
 
+CPPFLAGS="${CPPFLAGS} -DHAVE_EXPAT_CONFIG_H"
 AC_CONFIG_HEADER(expat_config.h)
 
 sinclude(conftools/ac_c_bigendian_cross.m4)
@@ -61,7 +63,7 @@ AC_SUBST(LIBREVISION)
 AC_SUBST(LIBAGE)
 
 dnl Checks for programs.
-AC_PROG_CC
+AC_PROG_CC_C99
 AC_PROG_CXX
 AC_PROG_INSTALL
 
@@ -77,7 +79,13 @@ if test "$GCC" = yes ; then
     AC_TRY_LINK( , ,
                    AC_MSG_RESULT(yes),
                    AC_MSG_RESULT(no); CFLAGS="$OLDCFLAGS")
+    if test "x$CXXFLAGS" = x ; then
     CXXFLAGS=`echo "$CFLAGS" | sed 's/ -Wmissing-prototypes -Wstrict-prototypes//'`
+    fi
+
+    CFLAGS="${CFLAGS} -fno-strict-aliasing"
+    CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
+    LDFLAGS="${LDFLAGS} -fno-strict-aliasing"
 fi
 
 dnl Checks for header files.
@@ -93,6 +101,96 @@ AC_C_CONST
 AC_TYPE_SIZE_T
 AC_CHECK_FUNCS(memmove bcopy)
 
+
+AC_ARG_WITH([xmlwf], [
+AS_HELP_STRING([--without-xmlwf], [do not build xmlwf])], [], [with_xmlwf=yes])
+AM_CONDITIONAL([WITH_XMLWF], [test x${with_xmlwf} = xyes])
+
+AM_CONDITIONAL([MINGW], [echo -- "${host}" | fgrep -q mingw])
+AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | fgrep -q XML_UNICODE])
+
+
+AC_ARG_WITH([libbsd], [
+AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])
+], [], [with_libbsd=no])
+AS_IF([test "x${with_libbsd}" != xno], [
+  AC_CHECK_LIB([bsd], [arc4random_buf], [], [
+    AS_IF([test "x${with_libbsd}" = xyes], [
+      AC_MSG_ERROR([Enforced use of libbsd cannot be satisfied.])
+    ])
+  ])
+])
+AC_MSG_CHECKING([for arc4random_buf (BSD or libbsd)])
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+  #include <stdlib.h>  /* for arc4random_buf on BSD, for NULL */
+  #if defined(HAVE_LIBBSD)
+  # include <bsd/stdlib.h>
+  #endif
+  int main() {
+    arc4random_buf(NULL, 0U);
+    return 0;
+  }
+])], [
+    AC_DEFINE([HAVE_ARC4RANDOM_BUF], [1],
+        [Define to 1 if you have the `arc4random_buf' function.])
+    AC_MSG_RESULT([yes])
+], [
+    AC_MSG_RESULT([no])
+
+    AC_MSG_CHECKING([for arc4random (BSD, macOS or libbsd)])
+    AC_LINK_IFELSE([AC_LANG_SOURCE([
+      #if defined(HAVE_LIBBSD)
+      # include <bsd/stdlib.h>
+      #else
+      # include <stdlib.h>
+      #endif
+      int main() {
+          arc4random();
+          return 0;
+      }
+    ])], [
+        AC_DEFINE([HAVE_ARC4RANDOM], [1],
+            [Define to 1 if you have the `arc4random' function.])
+        AC_MSG_RESULT([yes])
+    ], [
+        AC_MSG_RESULT([no])
+    ])
+])
+
+
+AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+  #include <stdlib.h>  /* for NULL */
+  #include <sys/random.h>
+  int main() {
+    return getrandom(NULL, 0U, 0U);
+  }
+])], [
+    AC_DEFINE([HAVE_GETRANDOM], [1],
+        [Define to 1 if you have the `getrandom' function.])
+    AC_MSG_RESULT([yes])
+], [
+    AC_MSG_RESULT([no])
+
+    AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
+    AC_LINK_IFELSE([AC_LANG_SOURCE([
+      #include <stdlib.h>  /* for NULL */
+      #include <unistd.h>  /* for syscall */
+      #include <sys/syscall.h>  /* for SYS_getrandom */
+      int main() {
+        syscall(SYS_getrandom, NULL, 0, 0);
+        return 0;
+      }
+    ])], [
+        AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
+            [Define to 1 if you have `syscall' and `SYS_getrandom'.])
+        AC_MSG_RESULT([yes])
+    ], [
+        AC_MSG_RESULT([no])
+    ])
+])
+
+
 dnl Only needed for xmlwf:
 AC_CHECK_HEADERS(fcntl.h unistd.h)
 AC_TYPE_OFF_T
@@ -105,51 +203,54 @@ else
 fi
 AC_SUBST(FILEMAP)
 
-dnl Needed for the test support code; this was found at
-dnl http://lists.gnu.org/archive/html/bug-autoconf/2002-07/msg00028.html
-
-# AC_CPP_FUNC
-# ------------------ #
-# Checks to see if ANSI C99 CPP variable __func__ works.
-# If not, perhaps __FUNCTION__ works instead. 
-# If not, we'll just define __func__ to "". 
-AC_DEFUN([AC_CPP_FUNC],
-[AC_REQUIRE([AC_PROG_CC_STDC])dnl
-AC_CACHE_CHECK([for an ANSI C99-conforming __func__], ac_cv_cpp_func,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
-[[char *foo = __func__;]])],
-  [ac_cv_cpp_func=yes], 
-  [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
-[[char *foo = __FUNCTION__;]])],
-  [ac_cv_cpp_func=__FUNCTION__], 
-  [ac_cv_cpp_func=no])])])
-if test $ac_cv_cpp_func = __FUNCTION__; then
-  AC_DEFINE(__func__,__FUNCTION__,
-            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
-ANSI C.])
-elif test $ac_cv_cpp_func = no; then
-  AC_DEFINE(__func__,"",
-            [Define to __FUNCTION__ or "" if `__func__' does not conform to 
-ANSI C.])
-fi
-])# AC_CPP_FUNC
-
-AC_CPP_FUNC
-
 
 dnl Some basic configuration:
 AC_DEFINE([XML_NS], 1,
           [Define to make XML Namespaces functionality available.])
 AC_DEFINE([XML_DTD], 1,
           [Define to make parameter entity parsing functionality available.])
-AC_DEFINE([XML_CONTEXT_BYTES], 1024,
-          [Define to specify how much context to retain around the current parse point.])
+AC_DEFINE([XML_DEV_URANDOM], 1,
+          [Define to include code reading entropy from `/dev/urandom'.])
+
+AC_ARG_ENABLE([xml-context],
+  AS_HELP_STRING([--enable-xml-context @<:@COUNT@:>@],
+    [Retain context around the current parse point;
+        default is enabled and a size of 1024 bytes])
+AS_HELP_STRING([--disable-xml-context],
+    [Do not retain context around the current parse point]),
+  [enable_xml_context=${enableval}])
+AS_IF([test "x${enable_xml_context}" != "xno"], [
+  AS_IF([test "x${enable_xml_context}" = "xyes" \
+      -o "x${enable_xml_context}" = "x"], [
+    enable_xml_context=1024
+  ])
+  AC_DEFINE_UNQUOTED([XML_CONTEXT_BYTES], [${enable_xml_context}],
+    [Define to specify how much context to retain around the current parse point.])
+])
+
+AC_ARG_WITH([docbook], [AS_HELP_STRING([--with-docbook],
+    [enforce XML to man page compilation @<:@default=check@:>@])
+AS_HELP_STRING([--without-docbook],
+    [skip XML to man page compilation @<:@default=check@:>@])],
+  [],
+  [with_docbook=check])
+
+AC_ARG_VAR([DOCBOOK_TO_MAN], [docbook2x-man command])
+AS_IF([test "x$with_docbook" != xno],
+  [AC_CHECK_PROGS([DOCBOOK_TO_MAN], [docbook2x-man docbook2man docbook-to-man],
+  [if test "x$with_docbook" != xcheck; then 
+    AC_MSG_ERROR([Required program 'docbook2x-man' not found.])])])
+
+AM_CONDITIONAL(WITH_DOCBOOK, [test x${DOCBOOK_TO_MAN} != x])
 
 AC_CONFIG_FILES([Makefile expat.pc])
+AC_CONFIG_FILES([
+  doc/Makefile
+  examples/Makefile
+  lib/Makefile
+  tests/Makefile
+  tests/benchmark/Makefile
+  xmlwf/Makefile
+])
+AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
 AC_OUTPUT
-
-abs_srcdir="`cd $srcdir && pwd`"
-abs_builddir="`pwd`"
-if test "$abs_srcdir" != "$abs_builddir"; then
-  make mkdir-init
-fi