tomato-testing/doc/building.md
Green Sky 67653bbe50 Squashed 'external/libwebp/libwebp/' content from commit dd7364c3c
git-subtree-dir: external/libwebp/libwebp
git-subtree-split: dd7364c3cefe0f5c0b3c18c3b1887d353f90fc1f
2023-08-02 14:57:22 +02:00

5.3 KiB

Building

Windows build

By running:

nmake /f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output

the directory output\release-static\(x64|x86)\bin will contain the tools cwebp.exe and dwebp.exe. The directory output\release-static\(x64|x86)\lib will contain the libwebp static library. The target architecture (x86/x64) is detected by Makefile.vc from the Visual Studio compiler (cl.exe) available in the system path.

Unix build using makefile.unix

On platforms with GNU tools installed (gcc and make), running

make -f makefile.unix

will build the binaries examples/cwebp and examples/dwebp, along with the static library src/libwebp.a. No system-wide installation is supplied, as this is a simple alternative to the full installation system based on the autoconf tools (see below). Please refer to makefile.unix for additional details and customizations.

Using autoconf tools

Prerequisites: a compiler (e.g., gcc), make, autoconf, automake, libtool.

On a Debian-like system the following should install everything you need for a minimal build:

$ sudo apt-get install gcc make autoconf automake libtool

When building from git sources, you will need to run autogen.sh to generate the configure script.

./configure
make
make install

should be all you need to have the following files

/usr/local/include/webp/decode.h
/usr/local/include/webp/encode.h
/usr/local/include/webp/types.h
/usr/local/lib/libwebp.*
/usr/local/bin/cwebp
/usr/local/bin/dwebp

installed.

Note: A decode-only library, libwebpdecoder, is available using the --enable-libwebpdecoder flag. The encode library is built separately and can be installed independently using a minor modification in the corresponding Makefile.am configure files (see comments there). See ./configure --help for more options.

Building for MIPS Linux

MIPS Linux toolchain stable available releases can be found at: https://community.imgtec.com/developers/mips/tools/codescape-mips-sdk/available-releases/

# Add toolchain to PATH
export PATH=$PATH:/path/to/toolchain/bin

# 32-bit build for mips32r5 (p5600)
HOST=mips-mti-linux-gnu
MIPS_CFLAGS="-O3 -mips32r5 -mabi=32 -mtune=p5600 -mmsa -mfp64 \
  -msched-weight -mload-store-pairs -fPIE"
MIPS_LDFLAGS="-mips32r5 -mabi=32 -mmsa -mfp64 -pie"

# 64-bit build for mips64r6 (i6400)
HOST=mips-img-linux-gnu
MIPS_CFLAGS="-O3 -mips64r6 -mabi=64 -mtune=i6400 -mmsa -mfp64 \
  -msched-weight -mload-store-pairs -fPIE"
MIPS_LDFLAGS="-mips64r6 -mabi=64 -mmsa -mfp64 -pie"

./configure --host=${HOST} --build=`config.guess` \
  CC="${HOST}-gcc -EL" \
  CFLAGS="$MIPS_CFLAGS" \
  LDFLAGS="$MIPS_LDFLAGS"
make
make install

CMake

With CMake, you can compile libwebp, cwebp, dwebp, gif2webp, img2webp, webpinfo and the JS bindings.

Prerequisites: a compiler (e.g., gcc with autotools) and CMake.

On a Debian-like system the following should install everything you need for a minimal build:

$ sudo apt-get install build-essential cmake

When building from git sources, you will need to run cmake to generate the makefiles.

mkdir build && cd build && cmake ../
make
make install

If you also want any of the executables, you will need to enable them through CMake, e.g.:

cmake -DWEBP_BUILD_CWEBP=ON -DWEBP_BUILD_DWEBP=ON ../

or through your favorite interface (like ccmake or cmake-qt-gui).

Use option -DWEBP_UNICODE=ON for Unicode support on Windows (with chcp 65001).

Finally, once installed, you can also use WebP in your CMake project by doing:

find_package(WebP)

which will define the CMake variables WebP_INCLUDE_DIRS and WebP_LIBRARIES.

Gradle

The support for Gradle is minimal: it only helps you compile libwebp, cwebp and dwebp and webpmux_example.

Prerequisites: a compiler (e.g., gcc with autotools) and gradle.

On a Debian-like system the following should install everything you need for a minimal build:

$ sudo apt-get install build-essential gradle

When building from git sources, you will need to run the Gradle wrapper with the appropriate target, e.g. :

./gradlew buildAllExecutables

SWIG bindings

To generate language bindings from swig/libwebp.swig at least swig-1.3 (http://www.swig.org) is required.

Currently the following functions are mapped:

Decode:

WebPGetDecoderVersion
WebPGetInfo
WebPDecodeRGBA
WebPDecodeARGB
WebPDecodeBGRA
WebPDecodeBGR
WebPDecodeRGB

Encode:

WebPGetEncoderVersion
WebPEncodeRGBA
WebPEncodeBGRA
WebPEncodeRGB
WebPEncodeBGR
WebPEncodeLosslessRGBA
WebPEncodeLosslessBGRA
WebPEncodeLosslessRGB
WebPEncodeLosslessBGR

See also the swig documentation for more detailed build instructions and usage examples.

Java bindings

To build the swig-generated JNI wrapper code at least JDK-1.5 (or equivalent) is necessary for enum support. The output is intended to be a shared object / DLL that can be loaded via System.loadLibrary("webp_jni").

Python bindings

To build the swig-generated Python extension code at least Python 2.6 is required. Python < 2.6 may build with some minor changes to libwebp.swig or the generated code, but is untested.

Javascript decoder

Libwebp can be compiled into a JavaScript decoder using Emscripten and CMake. See the corresponding documentation