[Pcre-svn] [478] code/trunk: Update configure.ac to solve li…

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [478] code/trunk: Update configure.ac to solve libbz2 problem under Win32.
Revision: 478
          http://vcs.pcre.org/viewvc?view=rev&revision=478
Author:   ph10
Date:     2010-01-03 16:05:13 +0000 (Sun, 03 Jan 2010)


Log Message:
-----------
Update configure.ac to solve libbz2 problem under Win32.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/configure.ac


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2010-01-03 15:53:09 UTC (rev 477)
+++ code/trunk/ChangeLog    2010-01-03 16:05:13 UTC (rev 478)
@@ -26,39 +26,49 @@
     assertion subpattern, including such a pattern used as a condition,
     unpredictable results occurred, instead of the error return
     PCRE_ERROR_DFA_UITEM.
-    
+
 5.  The C++ GlobalReplace function was not working like Perl for the special
     situation when an empty string is matched. It now does the fancy magic
-    stuff that is necessary. 
-    
-6.  In pcre_internal.h, obsolete includes to setjmp.h and stdarg.h have been 
+    stuff that is necessary.
+
+6.  In pcre_internal.h, obsolete includes to setjmp.h and stdarg.h have been
     removed. (These were left over from very, very early versions of PCRE.)
-    
+
 7.  Some cosmetic changes to the code to make life easier when compiling it
     as part of something else:
-    
-    (a) Change DEBUG to PCRE_DEBUG. 
-    
-    (b) In pcre_compile(), rename the member of the "branch_chain" structure 
-        called "current" as "current_branch", to prevent a collision with the 
+
+    (a) Change DEBUG to PCRE_DEBUG.
+
+    (b) In pcre_compile(), rename the member of the "branch_chain" structure
+        called "current" as "current_branch", to prevent a collision with the
         Linux macro when compiled as a kernel module.
-        
-    (c) In pcre_study(), rename the function set_bit() as set_table_bit(), to 
-        prevent a collision with the Linux macro when compiled as a kernel 
+
+    (c) In pcre_study(), rename the function set_bit() as set_table_bit(), to
+        prevent a collision with the Linux macro when compiled as a kernel
         module.
-        
+
 8.  In pcre_compile() there are some checks for integer overflows that used to
     cast potentially large values to (double). This has been changed to that
-    when building, a check for int64_t is made, and if it is found, it is used 
-    instead, thus avoiding the use of floating point arithmetic. (There is no 
-    other use of FP in PCRE.) If int64_t is not found, the fallback is to 
-    double. 
-    
-9.  Added two casts to avoid signed/unsigned warnings from VS Studio Express 
+    when building, a check for int64_t is made, and if it is found, it is used
+    instead, thus avoiding the use of floating point arithmetic. (There is no
+    other use of FP in PCRE.) If int64_t is not found, the fallback is to
+    double.
+
+9.  Added two casts to avoid signed/unsigned warnings from VS Studio Express
     2005 (difference between two addresses compared to an unsigned value).
-       


+10. Change the standard AC_CHECK_LIB test for libbz2 in configure.ac to a
+    custom one, because of the following reported problem in Windows:


+      - libbz2 uses the Pascal calling convention (WINAPI) for the functions
+        under Win32.
+      - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
+        therefore missing the function definition.
+      - The compiler thus generates a "C" signature for the test function.
+      - The linker fails to find the "C" function.
+      - PCRE fails to configure if asked to do so against libbz2.
+
+
 Version 8.00 19-Oct-09
 ----------------------



Modified: code/trunk/configure.ac
===================================================================
--- code/trunk/configure.ac    2010-01-03 15:53:09 UTC (rev 477)
+++ code/trunk/configure.ac    2010-01-03 16:05:13 UTC (rev 478)
@@ -368,11 +368,40 @@
 AC_CHECK_HEADERS([zlib.h], [HAVE_ZLIB_H=1])
 AC_CHECK_LIB([z], [gzopen], [HAVE_LIBZ=1])


-# Check for the availability of libbz2
+# Check for the availability of libbz2. Originally we just used AC_CHECK_LIB,
+# as for libz. However, this had the following problem, diagnosed and fixed by
+# a user:
+#
+#   - libbz2 uses the Pascal calling convention (WINAPI) for the functions
+#     under Win32.
+#   - The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
+#     therefore missing the function definition.
+#   - The compiler thus generates a "C" signature for the test function.
+#   - The linker fails to find the "C" function.
+#   - PCRE fails to configure if asked to do so against libbz2.
+#
+# Solution:
+#
+#   - Replace the AC_CHECK_LIB test with a custom test.


AC_CHECK_HEADERS([bzlib.h], [HAVE_BZLIB_H=1])
-AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
+# Original test
+# AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])
+#
+# Custom test follows

+AC_MSG_CHECKING([for libbz2])
+OLD_LIBS="$LIBS"
+LIBS="$LIBS -lbz2"
+AC_LINK_IFELSE( AC_LANG_PROGRAM([[
+#ifdef HAVE_BZLIB_H
+#include <bzlib.h>
+#endif]],
+[[return (int)BZ2_bzopen("conftest", "rb");]]),
+[AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
+AC_MSG_RESULT([no]))
+LIBS="$OLD_LIBS"
+
# Check for the availabiity of libreadline

AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_H=1])