blob: 7b3afb5c5193a7b4f992321a729e456bb9d61fd0 (
plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# Compiling Bzip2
> **Directory**: `bzip2/`
> **Build Systems**: Meson (preferred), CMake
> **Latest Version**: 0.0.5-1
---
## Overview
Bzip2 supports two build systems. **Meson** is preferred for Unix-like systems, while **CMake** provides cross-platform support.
---
## Build Systems Comparison
| Feature | Meson | CMake |
|---------|-------|-------|
| Unix Support | ✅ Excellent | ✅ Good |
| Windows Support | ✅ Good | ✅ Excellent |
| Preferred For | Unix-like | Cross-platform |
---
## Prerequisites
### All Platforms
- Python 3.6+
- C compiler (GCC, Clang, or MSVC)
### Meson Builds
- Meson 0.56+
- Ninja
- pkg-config
### CMake Builds
- CMake 3.12+
---
## Meson Build
### Linux/macOS
```bash
cd bzip2
# Configure
meson setup builddir --prefix=/usr
# Build
ninja -C builddir
# Test
meson test -C builddir --print-errorlogs
# Install (optional)
sudo ninja -C builddir install
```
### Windows (MSVC)
```cmd
cd bzip2
REM From VS Developer Command Prompt
meson setup builddir
ninja -C builddir
meson test -C builddir --print-errorlogs
```
### Meson Options
| Option | Default | Description |
|--------|---------|-------------|
| `default_library` | `shared` | `static`, `shared`, or `both` |
| `--backend` | `ninja` | Use `vs` for MSBuild |
| `--unity` | off | Enable unity build |
| `buildtype` | `debug` | `release`, `debug`, etc. |
---
## CMake Build
### Linux/macOS
```bash
cd bzip2
mkdir build && cd build
# Configure
cmake .. -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build .
# Test
ctest -V
# Install (optional)
cmake --install .
```
### Windows
```powershell
cd bzip2
mkdir build; cd build
# Configure
cmake ..
# Build (Release)
cmake --build . --config Release
# Test
ctest -C Release -V
```
### CMake Options
| Option | Default | Description |
|--------|---------|-------------|
| `ENABLE_APP` | `ON` | Build bzip2 program |
| `ENABLE_LIB_ONLY` | `OFF` | Only build library |
| `ENABLE_STATIC_LIB` | `OFF` | Build static library |
| `ENABLE_SHARED_LIB` | `ON` | Build shared library |
| `ENABLE_TESTS` | `ON` | Build tests |
| `ENABLE_DOCS` | `OFF` | Generate documentation |
| `ENABLE_EXAMPLES` | `OFF` | Build examples |
| `USE_OLD_SONAME` | `OFF` | Use old SONAME (distro compat) |
---
## SONAME Compatibility (Linux)
The SONAME changed from `libbz2.so.1.0` to `libbz2.so.1` in version 1.1.
For distro compatibility:
```bash
# Option 1: CMake flag
cmake .. -DUSE_OLD_SONAME=ON
# Option 2: Manual patchelf
patchelf --set-soname libbz2.so.1.0 libbz2.so.1.0.9
```
Check SONAME:
```bash
objdump -p libbz2.so.1.0.9 | grep SONAME
```
---
## Related Documentation
- [Bzip2 Overview](./bzip2.md) — Main documentation
- [Bzip2 Tests](./bzip2-tests.md) — Test suite
- [Bzip2 Test Files](./bzip2-testfiles.md) — Test file collection
|