1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
AC_INIT(libbzip2mod.cmod) 
AC_CONFIG_HEADER(libbzip2mod_config.h) 
AC_ARG_WITH(bz2,     [  --without-bz2       Disable Bz2],[],[with_bz2=yes]) 
 
AC_MODULE_INIT() 
 
PIKE_FEATURE_WITHOUT(Bz2) 
 
if test x$with_bz2 = xyes ; then 
  PIKE_FEATURE(Bz2,[no (missing lib)]) 
 
  # NB: bzCompressInit always exists in bz2. 
  # no, it doesn't. /Mirar 
  # Or the lib might be called bzip2.lib in GnuWin32. /mast 
 
  AC_SEARCH_LIBS(BZ2_bzCompressInit, bz2 bzip2, 
    bz2_lib_found=yes, [ 
    AC_SEARCH_LIBS(bzCompressInit, bz2 bzip2, 
      bz2_lib_found=yes) 
    ]) 
 
  if test "x$bz2_lib_found" = xyes; then 
 
    # Must be before AC_CHECK_FUNCS for PIKE_FUNCS_NEED_DECLS to work. 
    AC_CHECK_HEADERS(bzlib.h string.h strings.h) 
 
    # if BZ2_bzCompressInit exists, 
    # it should be used instead of bzCompressInit. 
    AC_CHECK_FUNCS(BZ2_bzCompressInit) 
 
    if test $ac_cv_header_bzlib_h = yes ; then 
      AC_MSG_CHECKING(if the library works) 
      AC_CACHE_VAL(pike_cv_bz_works, [ 
        AC_TRY_RUN([ 
/* bzlib.h needs stdio.h on some systems (for FILE) */ 
#include <stdio.h> 
#include <bzlib.h> 
 
#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 
        ]) 
      ]) 
      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 
      fi 
    else 
      PIKE_FEATURE(Bz2,[no (got libbz2 but missing bzlib.h)]) 
    fi 
  fi 
fi 
 
AC_OUTPUT(Makefile,echo FOO >stamp-h )