Commit 3ae11daa authored by Federico Mena Quintero's avatar Federico Mena Quintero

Merge branch 'dcbaker/bzip2-compiling'

parents fa2a2417 9ab83fc1
Pipeline #66252554 passed with stage
in 2 minutes and 44 seconds
# Compiling bzip2
There are three build systems currently for building bzip2: meson, autotools,
and nmake
Autotools is only supported on Unix-like OSes, nmake is only for Windows,
meson works for both.
## Using meson
Meson provides a [large number of built-in options](https://mesonbuild.com/Builtin-options.html)
to control compilation. A few important ones are listed below:
- -Ddefault_library=[static|shared|both], defaults to shared, if you wish to
statically link libbz2 into the binaries set this to `static`
- --backend : defaults to ninja, use `vs` if you want to use msbuild
- --unity : This enables a unity build (sometimes called a jumbo build), makes a single build faster but rebuilds slower
- -Dbuildtype=[debug|debugoptmized|release|minsize|plain] : Controls default optimization/debug generation args,
defaults to `debug`, use `plain` if you wish to pass your own cflags.
Meson recognizes environment variables like $CFLAGS and $CC, it is recommended
that you do not use $CFLAGS, and instead use -Dc_args and -DC_link_args, as
meson will remember these even if you need to reconfigure from scratch (such
as when you update meson), it will not remember $CFLAGS.
Meson will never change compilers once configured, so $CC is perfectly safe.
### Unix-like (Linux, *BSD, Cygwin, macOS)
You will need
- Python 3.5 or newer (for meson)
- meson (Verison 0.48 or newer)
- ninja
- pkg-config
- A C compiler such as GCC or Clang
Some linux distros package managers refer to ninja as ninja-build, fedora
and debian/ubuntu both do this. Your OS probably provides meson, although
it may be too old, in that case you can use python3's pip to install meson:
```sh
sudo pip3 install meson
```
or, for a user local install:
```sh
pip3 install --user meson
```
Once you have installed the dependencies you will use the standard meson
configuration, ninja build:
```sh
meson builddir/
ninja -C builddir
[sudo] ninja -C builddir install
```
You can use `meson configure builddir` to check configuration options.
Currently bzip only has one project specific option, which is to force the
generation of documentation on or off.
Ninja acepts many of the same arguments as make, although it will
automatically detect the number of CPU cores available and use an appropriate
number of threads.
### Windows
You will need to either download python 3.5 or newer and install with pip:
```cmd
py -m pip install meson
```
or you can [download pre-bundled installers of meson directly from meson's github](https://github.com/mesonbuild/meson/releases).
Either should work fine for the purposes of building bzip2
You will also need pkg-config. There are many sources of pkg-config, I
recommend installing from chocolatey because it's easy. chocolatey can also
provide ninja, though ninja is not required on windows if you want to use
msbuild.
If you want to use MSVC or a compatible compiler launch the associated
environment cmd to run meson from; the environments required to make those
compilers work is quite complex otherwise.
Once you have all of that installed you can invoke meson to configure the
build. By default meson will generate a ninja backend, if you would prefer to
use msbuild pass the backend flag `--backend=vs`. MSVC (and compatible
compilers like clang-cl and ICL) work with ninja as well.
```cmd
meson $builddir
ninja -C $builddir
```
or:
```cmd
meson $builddir --backend=vs
cd $builddir
msbuild bzip2.sln /m
```
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment