da635a2003-01-22Andreas Finnman AC_INIT(libbzip2mod.cmod) AC_CONFIG_HEADER(libbzip2mod_config.h)
1b0a8a2003-01-25Mirar (Pontus Hagland) AC_ARG_WITH(bz2, [ --without-bz2 Disable Bz2],[],[with_bz2=yes])
da635a2003-01-22Andreas Finnman  AC_MODULE_INIT()
1b0a8a2003-01-25Mirar (Pontus Hagland) PIKE_FEATURE_WITHOUT(Bz2) if test x$with_bz2 = xyes ; then
6b31002008-07-19Martin Stjernholm  PIKE_FEATURE(Bz2,[no (missing lib)])
da635a2003-01-22Andreas Finnman 
7aa3852003-01-23Henrik Grubbström (Grubba)  # NB: bzCompressInit always exists in bz2.
1b0a8a2003-01-25Mirar (Pontus Hagland)  # no, it doesn't. /Mirar
6b31002008-07-19Martin Stjernholm  # Or the lib might be called bzip2.lib in GnuWin32. /mast
1b0a8a2003-01-25Mirar (Pontus Hagland) 
6b31002008-07-19Martin Stjernholm  AC_SEARCH_LIBS(BZ2_bzCompressInit, bz2 bzip2, bz2_lib_found=yes, [ AC_SEARCH_LIBS(bzCompressInit, bz2 bzip2, bz2_lib_found=yes) ])
1b0a8a2003-01-25Mirar (Pontus Hagland) 
6b31002008-07-19Martin Stjernholm  if test "x$bz2_lib_found" = xyes; then
1b0a8a2003-01-25Mirar (Pontus Hagland) 
4824e82006-07-04Martin Stjernholm  # Must be before AC_CHECK_FUNCS for PIKE_FUNCS_NEED_DECLS to work. AC_CHECK_HEADERS(bzlib.h string.h strings.h)
1b0a8a2003-01-25Mirar (Pontus Hagland)  # if BZ2_bzCompressInit exists, # it should be used instead of bzCompressInit. AC_CHECK_FUNCS(BZ2_bzCompressInit)
70e56c2003-01-25Henrik Grubbström (Grubba)  if test $ac_cv_header_bzlib_h = yes ; then
c309862007-07-17Henrik Grubbström (Grubba)  AC_MSG_CHECKING(if the library works) AC_CACHE_VAL(pike_cv_bz_works, [ AC_TRY_RUN([
9e02442003-01-26Mirar (Pontus Hagland) /* bzlib.h needs stdio.h on some systems (for FILE) */ #include <stdio.h>
5e583f2003-01-25Henrik Grubbström (Grubba) #include <bzlib.h>
c309862007-07-17Henrik Grubbström (Grubba)  #ifdef HAVE_BZ2_BZCOMPRESSINIT #define bzCompressInit BZ2_bzCompressInit #define bzDecompressInit BZ2_bzDecompressInit #endif static bz_stream s1 = { 0, }; static bz_stream s2 = { 0, }; int main(int argc, char **argv) { int ret; ret = bzCompressInit(&s1, 9, 0, 30); if (ret != BZ_OK) { fprintf(stderr, "bzCompressInit() failed with code: %d\n", ret); return 1; } ret = bzDecompressInit(&s2, 0, 0); if (ret != BZ_OK) { fprintf(stderr, "bzDecompressInit() failed with code: %d\n", ret); return 1; } return 0; } ], [pike_cv_bz_works=yes], [pike_cv_bz_works=no], [ pike_cv_bz_works=unknown ])
5e583f2003-01-25Henrik Grubbström (Grubba)  ])
c309862007-07-17Henrik Grubbström (Grubba)  AC_MSG_RESULT($pike_cv_bz_works) if test "$pike_cv_bz_works" = no; then PIKE_FEATURE(Bz2,[no (broken libbz2)]) else PIKE_FEATURE(Bz2,[yes (using libbz2)]) AC_DEFINE(HAVE_BZ2LIB) AC_MSG_CHECKING([if a bz_stream has the field total_out.]) AC_CACHE_VAL([pike_cv_bz_stream_total_out],[ AC_TRY_LINK([ /* bzlib.h needs stdio.h on some systems (for FILE) */ #include <stdio.h> #include <bzlib.h> ],[ extern bz_stream *s; s->total_out = 0; return 0; ],[ pike_cv_bz_stream_total_out="yes" ],[ pike_cv_bz_stream_total_out="no" ]) ]) AC_MSG_RESULT($pike_cv_bz_stream_total_out) if test "x$pike_cv_bz_stream_total_out" = xyes; then AC_DEFINE(HAVE_BZ_STREAM_TOTAL_OUT) fi
5e583f2003-01-25Henrik Grubbström (Grubba)  fi
1b0a8a2003-01-25Mirar (Pontus Hagland)  else
c309862007-07-17Henrik Grubbström (Grubba)  PIKE_FEATURE(Bz2,[no (got libbz2 but missing bzlib.h)])
1b0a8a2003-01-25Mirar (Pontus Hagland)  fi fi
da635a2003-01-22Andreas Finnman fi AC_OUTPUT(Makefile,echo FOO >stamp-h )