Author Topic: help_plugin - use system zlib and bzip2  (Read 4379 times)

Offline SharkCZ

  • Almost regular
  • **
  • Posts: 134
help_plugin - use system zlib and bzip2
« on: September 07, 2007, 02:46:48 pm »
I have found that the help_plugin includes its own copy of zlib and parts of bzip2. I have created a patch for autotools that tries to use system zlib and bzip2 when they are available.

Code
Index: configure.in
===================================================================
--- configure.in (revision 4437)
+++ configure.in (working copy)
@@ -49,6 +49,15 @@
 AC_CHECK_FUNC(snprintf, AC_DEFINE(HAVE_SNPRINTF,,snprintf))
 AC_CHECK_FUNC(vsnprintf, AC_DEFINE(HAVE_VSNPRINTF,,vsnprintf))
 
+save_LIBS=$LIBS
+AC_SEARCH_LIBS(gzopen, z, [HAVE_ZLIB=yes], [HAVE_ZLIB=no])
+LIBS=$save_LIBS
+AC_SEARCH_LIBS(BZ2_bzopen, bz2, [HAVE_BZIP2=yes], [HAVE_BZIP2=no])
+LIBS=$save_LIBS
+
+AM_CONDITIONAL([HAVE_ZLIB], [test "$HAVE_ZLIB" = yes])
+AM_CONDITIONAL([HAVE_BZIP2], [test "$HAVE_BZIP2" = yes])
+
 dnl versioning info for libtool
 dnl Note this is the ABI version which is not the same as our actual library version
 CODEBLOCKS_CURRENT=0
Index: src/plugins/contrib/help_plugin/Makefile.am
===================================================================
--- src/plugins/contrib/help_plugin/Makefile.am (revision 4437)
+++ src/plugins/contrib/help_plugin/Makefile.am (working copy)
@@ -1,4 +1,11 @@
-SUBDIRS = bzip2 zlib
+DIST_SUBDIRS = bzip2 zlib
+SUBDIRS =
+if ! HAVE_BZIP2
+SUBDIRS += bzip2
+endif
+if ! HAVE_ZLIB
+SUBDIRS += zlib
+endif
 
 INCLUDES = $(WX_CXXFLAGS) \
  -I$(top_srcdir)/src/include \
@@ -11,9 +18,19 @@
 
 libhelp_plugin_la_LDFLAGS = -module -version-info 0:1:0 -shared -no-undefined -avoid-version
 
-libhelp_plugin_la_LIBADD = $(PLUGIN_WX_LIBS) ../../../sdk/libcodeblocks.la \
- bzip2/libbzip2.la \
- zlib/libz.la
+libhelp_plugin_la_LIBADD = $(PLUGIN_WX_LIBS) ../../../sdk/libcodeblocks.la
+if ! HAVE_BZIP2
+libhelp_plugin_la_LIBADD += bzip2/libbzip2.la
+INCLUDES += -Ibzip2
+else
+libhelp_plugin_la_LIBADD += -lbz2
+endif
+if ! HAVE_ZLIB
+libhelp_plugin_la_LIBADD += zlib/libz.la
+INCLUDES += -Izlib
+else
+libhelp_plugin_la_LIBADD += -lz
+endif
 
 libhelp_plugin_la_SOURCES = help_common.cpp \
  HelpConfigDialog.cpp \
Index: src/plugins/contrib/help_plugin/help_plugin.cpp
===================================================================
--- src/plugins/contrib/help_plugin/help_plugin.cpp (revision 4437)
+++ src/plugins/contrib/help_plugin/help_plugin.cpp (working copy)
@@ -25,9 +25,10 @@
 
 #include "help_plugin.h"
 #include "man2html.h"
-#include "bzip2/bzlib.h"
-#include "zlib/zlib.h"
 
+#include <bzlib.h>
+#include <zlib.h>
+
 #include <wx/process.h>
 #include <wx/intl.h>
 #include <wx/textdlg.h>

Also filled as patch #2167, patch updated to fix #includes
« Last Edit: September 07, 2007, 03:08:33 pm by SharkCZ »
Code::Blocks package maintainer for Fedora and EPEL

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: help_plugin - use system zlib and bzip2
« Reply #1 on: September 07, 2007, 07:32:00 pm »
Wow, it's nice to see a patch like this in such a short time after the commit. I almost get a brain leak trying to figure out how to get bootstrap and configure to create the extra Makefiles from the Makefile.am files :P

I'll check it more carefully in a few hours (I just woke up) :wink: