xref: /aosp_15_r20/external/libjpeg-turbo/BUILDING.md (revision dfc6aa5c1cfd4bc4e2018dc74aa96e29ee49c6da)
1*dfc6aa5cSAndroid Build Coastguard WorkerBuilding libjpeg-turbo
2*dfc6aa5cSAndroid Build Coastguard Worker======================
3*dfc6aa5cSAndroid Build Coastguard Worker
4*dfc6aa5cSAndroid Build Coastguard Worker
5*dfc6aa5cSAndroid Build Coastguard WorkerBuild Requirements
6*dfc6aa5cSAndroid Build Coastguard Worker------------------
7*dfc6aa5cSAndroid Build Coastguard Worker
8*dfc6aa5cSAndroid Build Coastguard Worker
9*dfc6aa5cSAndroid Build Coastguard Worker### All Systems
10*dfc6aa5cSAndroid Build Coastguard Worker
11*dfc6aa5cSAndroid Build Coastguard Worker- [CMake](http://www.cmake.org) v2.8.12 or later
12*dfc6aa5cSAndroid Build Coastguard Worker
13*dfc6aa5cSAndroid Build Coastguard Worker- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
14*dfc6aa5cSAndroid Build Coastguard Worker  (if building x86 or x86-64 SIMD extensions)
15*dfc6aa5cSAndroid Build Coastguard Worker  * If using NASM, 2.13 or later is required.
16*dfc6aa5cSAndroid Build Coastguard Worker  * If using Yasm, 1.2.0 or later is required.
17*dfc6aa5cSAndroid Build Coastguard Worker  * If building on macOS, NASM or Yasm can be obtained from
18*dfc6aa5cSAndroid Build Coastguard Worker    [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
19*dfc6aa5cSAndroid Build Coastguard Worker     - NOTE: Currently, if it is desirable to hide the SIMD function symbols in
20*dfc6aa5cSAndroid Build Coastguard Worker       Mac executables or shared libraries that statically link with
21*dfc6aa5cSAndroid Build Coastguard Worker       libjpeg-turbo, then NASM 2.14 or later or Yasm must be used when
22*dfc6aa5cSAndroid Build Coastguard Worker       building libjpeg-turbo.
23*dfc6aa5cSAndroid Build Coastguard Worker  * If NASM or Yasm is not in your `PATH`, then you can specify the full path
24*dfc6aa5cSAndroid Build Coastguard Worker    to the assembler by using either the `CMAKE_ASM_NASM_COMPILER` CMake
25*dfc6aa5cSAndroid Build Coastguard Worker    variable or the `ASM_NASM` environment variable.  On Windows, use forward
26*dfc6aa5cSAndroid Build Coastguard Worker    slashes rather than backslashes in the path (for example,
27*dfc6aa5cSAndroid Build Coastguard Worker    **c:/nasm/nasm.exe**).
28*dfc6aa5cSAndroid Build Coastguard Worker  * NASM and Yasm are located in the CRB (Code Ready Builder) or PowerTools
29*dfc6aa5cSAndroid Build Coastguard Worker    repository on Red Hat Enterprise Linux 8+ and derivatives, which is not
30*dfc6aa5cSAndroid Build Coastguard Worker    enabled by default.
31*dfc6aa5cSAndroid Build Coastguard Worker
32*dfc6aa5cSAndroid Build Coastguard Worker### Un*x Platforms (including Linux, Mac, FreeBSD, Solaris, and Cygwin)
33*dfc6aa5cSAndroid Build Coastguard Worker
34*dfc6aa5cSAndroid Build Coastguard Worker- GCC v4.1 (or later) or Clang recommended for best performance
35*dfc6aa5cSAndroid Build Coastguard Worker
36*dfc6aa5cSAndroid Build Coastguard Worker- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
37*dfc6aa5cSAndroid Build Coastguard Worker  required.  Most modern Linux distributions, as well as Solaris 10 and later,
38*dfc6aa5cSAndroid Build Coastguard Worker  include JDK or OpenJDK.  For other systems, you can obtain the Oracle Java
39*dfc6aa5cSAndroid Build Coastguard Worker  Development Kit from
40*dfc6aa5cSAndroid Build Coastguard Worker  <http://www.oracle.com/technetwork/java/javase/downloads>.
41*dfc6aa5cSAndroid Build Coastguard Worker
42*dfc6aa5cSAndroid Build Coastguard Worker  * If using JDK 11 or later, CMake 3.10.x or later must also be used.
43*dfc6aa5cSAndroid Build Coastguard Worker
44*dfc6aa5cSAndroid Build Coastguard Worker### Windows
45*dfc6aa5cSAndroid Build Coastguard Worker
46*dfc6aa5cSAndroid Build Coastguard Worker- Microsoft Visual C++ 2005 or later
47*dfc6aa5cSAndroid Build Coastguard Worker
48*dfc6aa5cSAndroid Build Coastguard Worker  If you don't already have Visual C++, then the easiest way to get it is by
49*dfc6aa5cSAndroid Build Coastguard Worker  installing
50*dfc6aa5cSAndroid Build Coastguard Worker  [Visual Studio Community Edition](https://visualstudio.microsoft.com),
51*dfc6aa5cSAndroid Build Coastguard Worker  which includes everything necessary to build libjpeg-turbo.
52*dfc6aa5cSAndroid Build Coastguard Worker
53*dfc6aa5cSAndroid Build Coastguard Worker  * You can also download and install the standalone Windows SDK (for Windows 7
54*dfc6aa5cSAndroid Build Coastguard Worker    or later), which includes command-line versions of the 32-bit and 64-bit
55*dfc6aa5cSAndroid Build Coastguard Worker    Visual C++ compilers.
56*dfc6aa5cSAndroid Build Coastguard Worker  * If you intend to build libjpeg-turbo from the command line, then add the
57*dfc6aa5cSAndroid Build Coastguard Worker    appropriate compiler and SDK directories to the `INCLUDE`, `LIB`, and
58*dfc6aa5cSAndroid Build Coastguard Worker    `PATH` environment variables.  This is generally accomplished by
59*dfc6aa5cSAndroid Build Coastguard Worker    executing `vcvars32.bat` or `vcvars64.bat`, which are located in the same
60*dfc6aa5cSAndroid Build Coastguard Worker    directory as the compiler.
61*dfc6aa5cSAndroid Build Coastguard Worker  * If built with Visual C++ 2015 or later, the libjpeg-turbo static libraries
62*dfc6aa5cSAndroid Build Coastguard Worker    cannot be used with earlier versions of Visual C++, and vice versa.
63*dfc6aa5cSAndroid Build Coastguard Worker  * The libjpeg API DLL (**jpeg{version}.dll**) will depend on the C run-time
64*dfc6aa5cSAndroid Build Coastguard Worker    DLLs corresponding to the version of Visual C++ that was used to build it.
65*dfc6aa5cSAndroid Build Coastguard Worker
66*dfc6aa5cSAndroid Build Coastguard Worker   ... OR ...
67*dfc6aa5cSAndroid Build Coastguard Worker
68*dfc6aa5cSAndroid Build Coastguard Worker- MinGW
69*dfc6aa5cSAndroid Build Coastguard Worker
70*dfc6aa5cSAndroid Build Coastguard Worker  [MSYS2](http://msys2.github.io/) or [tdm-gcc](http://tdm-gcc.tdragon.net/)
71*dfc6aa5cSAndroid Build Coastguard Worker  recommended if building on a Windows machine.  Both distributions install a
72*dfc6aa5cSAndroid Build Coastguard Worker  Start Menu link that can be used to launch a command prompt with the
73*dfc6aa5cSAndroid Build Coastguard Worker  appropriate compiler paths automatically set.
74*dfc6aa5cSAndroid Build Coastguard Worker
75*dfc6aa5cSAndroid Build Coastguard Worker- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required.  This
76*dfc6aa5cSAndroid Build Coastguard Worker  can be downloaded from
77*dfc6aa5cSAndroid Build Coastguard Worker  <http://www.oracle.com/technetwork/java/javase/downloads>.
78*dfc6aa5cSAndroid Build Coastguard Worker
79*dfc6aa5cSAndroid Build Coastguard Worker  * If using JDK 11 or later, CMake 3.10.x or later must also be used.
80*dfc6aa5cSAndroid Build Coastguard Worker
81*dfc6aa5cSAndroid Build Coastguard Worker
82*dfc6aa5cSAndroid Build Coastguard WorkerSub-Project Builds
83*dfc6aa5cSAndroid Build Coastguard Worker------------------
84*dfc6aa5cSAndroid Build Coastguard Worker
85*dfc6aa5cSAndroid Build Coastguard WorkerThe libjpeg-turbo build system does not support being included as a sub-project
86*dfc6aa5cSAndroid Build Coastguard Workerusing the CMake `add_subdirectory()` function.  Use the CMake
87*dfc6aa5cSAndroid Build Coastguard Worker`ExternalProject_Add()` function instead.
88*dfc6aa5cSAndroid Build Coastguard Worker
89*dfc6aa5cSAndroid Build Coastguard Worker
90*dfc6aa5cSAndroid Build Coastguard WorkerOut-of-Tree Builds
91*dfc6aa5cSAndroid Build Coastguard Worker------------------
92*dfc6aa5cSAndroid Build Coastguard Worker
93*dfc6aa5cSAndroid Build Coastguard WorkerBinary objects, libraries, and executables are generated in the directory from
94*dfc6aa5cSAndroid Build Coastguard Workerwhich CMake is executed (the "binary directory"), and this directory need not
95*dfc6aa5cSAndroid Build Coastguard Workernecessarily be the same as the libjpeg-turbo source directory.  You can create
96*dfc6aa5cSAndroid Build Coastguard Workermultiple independent binary directories, in which different versions of
97*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg-turbo can be built from the same source tree using different compilers
98*dfc6aa5cSAndroid Build Coastguard Workeror settings.  In the sections below, *{build_directory}* refers to the binary
99*dfc6aa5cSAndroid Build Coastguard Workerdirectory, whereas *{source_directory}* refers to the libjpeg-turbo source
100*dfc6aa5cSAndroid Build Coastguard Workerdirectory.  For in-tree builds, these directories are the same.
101*dfc6aa5cSAndroid Build Coastguard Worker
102*dfc6aa5cSAndroid Build Coastguard Worker
103*dfc6aa5cSAndroid Build Coastguard WorkerNinja
104*dfc6aa5cSAndroid Build Coastguard Worker-----
105*dfc6aa5cSAndroid Build Coastguard Worker
106*dfc6aa5cSAndroid Build Coastguard WorkerIf using Ninja, then replace `make` or `nmake` with `ninja`, and replace the
107*dfc6aa5cSAndroid Build Coastguard WorkerCMake generator (specified with the `-G` option) with `Ninja`, in all of the
108*dfc6aa5cSAndroid Build Coastguard Workerprocedures and recipes below.
109*dfc6aa5cSAndroid Build Coastguard Worker
110*dfc6aa5cSAndroid Build Coastguard Worker
111*dfc6aa5cSAndroid Build Coastguard WorkerBuild Procedure
112*dfc6aa5cSAndroid Build Coastguard Worker---------------
113*dfc6aa5cSAndroid Build Coastguard Worker
114*dfc6aa5cSAndroid Build Coastguard WorkerNOTE: The build procedures below assume that CMake is invoked from the command
115*dfc6aa5cSAndroid Build Coastguard Workerline, but all of these procedures can be adapted to the CMake GUI as
116*dfc6aa5cSAndroid Build Coastguard Workerwell.
117*dfc6aa5cSAndroid Build Coastguard Worker
118*dfc6aa5cSAndroid Build Coastguard Worker
119*dfc6aa5cSAndroid Build Coastguard Worker### Un*x
120*dfc6aa5cSAndroid Build Coastguard Worker
121*dfc6aa5cSAndroid Build Coastguard WorkerThe following procedure will build libjpeg-turbo on Unix and Unix-like systems.
122*dfc6aa5cSAndroid Build Coastguard Worker(On Solaris, this generates a 32-bit build.  See "Build Recipes" below for
123*dfc6aa5cSAndroid Build Coastguard Worker64-bit build instructions.)
124*dfc6aa5cSAndroid Build Coastguard Worker
125*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
126*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" [additional CMake flags] {source_directory}
127*dfc6aa5cSAndroid Build Coastguard Worker    make
128*dfc6aa5cSAndroid Build Coastguard Worker
129*dfc6aa5cSAndroid Build Coastguard WorkerThis will generate the following files under *{build_directory}*:
130*dfc6aa5cSAndroid Build Coastguard Worker
131*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.a**<br>
132*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the libjpeg API
133*dfc6aa5cSAndroid Build Coastguard Worker
134*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.so.{version}** (Linux, Unix)<br>
135*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.{version}.dylib** (Mac)<br>
136*dfc6aa5cSAndroid Build Coastguard Worker**cygjpeg-{version}.dll** (Cygwin)<br>
137*dfc6aa5cSAndroid Build Coastguard WorkerShared library for the libjpeg API
138*dfc6aa5cSAndroid Build Coastguard Worker
139*dfc6aa5cSAndroid Build Coastguard WorkerBy default, *{version}* is 62.2.0, 7.2.0, or 8.1.2, depending on whether
140*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg v6b (default), v7, or v8 emulation is enabled.  If using Cygwin,
141*dfc6aa5cSAndroid Build Coastguard Worker*{version}* is 62, 7, or 8.
142*dfc6aa5cSAndroid Build Coastguard Worker
143*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.so** (Linux, Unix)<br>
144*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.dylib** (Mac)<br>
145*dfc6aa5cSAndroid Build Coastguard WorkerDevelopment symlink for the libjpeg API
146*dfc6aa5cSAndroid Build Coastguard Worker
147*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.dll.a** (Cygwin)<br>
148*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the libjpeg API
149*dfc6aa5cSAndroid Build Coastguard Worker
150*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.a**<br>
151*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the TurboJPEG API
152*dfc6aa5cSAndroid Build Coastguard Worker
153*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.so.0.2.0** (Linux, Unix)<br>
154*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.0.2.0.dylib** (Mac)<br>
155*dfc6aa5cSAndroid Build Coastguard Worker**cygturbojpeg-0.dll** (Cygwin)<br>
156*dfc6aa5cSAndroid Build Coastguard WorkerShared library for the TurboJPEG API
157*dfc6aa5cSAndroid Build Coastguard Worker
158*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.so** (Linux, Unix)<br>
159*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.dylib** (Mac)<br>
160*dfc6aa5cSAndroid Build Coastguard WorkerDevelopment symlink for the TurboJPEG API
161*dfc6aa5cSAndroid Build Coastguard Worker
162*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.dll.a** (Cygwin)<br>
163*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the TurboJPEG API
164*dfc6aa5cSAndroid Build Coastguard Worker
165*dfc6aa5cSAndroid Build Coastguard Worker
166*dfc6aa5cSAndroid Build Coastguard Worker### Visual C++ (Command Line)
167*dfc6aa5cSAndroid Build Coastguard Worker
168*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
169*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release [additional CMake flags] {source_directory}
170*dfc6aa5cSAndroid Build Coastguard Worker    nmake
171*dfc6aa5cSAndroid Build Coastguard Worker
172*dfc6aa5cSAndroid Build Coastguard WorkerThis will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
173*dfc6aa5cSAndroid Build Coastguard Workeron which version of **cl.exe** is in the `PATH`.
174*dfc6aa5cSAndroid Build Coastguard Worker
175*dfc6aa5cSAndroid Build Coastguard WorkerThe following files will be generated under *{build_directory}*:
176*dfc6aa5cSAndroid Build Coastguard Worker
177*dfc6aa5cSAndroid Build Coastguard Worker**jpeg-static.lib**<br>
178*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the libjpeg API
179*dfc6aa5cSAndroid Build Coastguard Worker
180*dfc6aa5cSAndroid Build Coastguard Worker**jpeg{version}.dll**<br>
181*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the libjpeg API
182*dfc6aa5cSAndroid Build Coastguard Worker
183*dfc6aa5cSAndroid Build Coastguard Worker**jpeg.lib**<br>
184*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the libjpeg API
185*dfc6aa5cSAndroid Build Coastguard Worker
186*dfc6aa5cSAndroid Build Coastguard Worker**turbojpeg-static.lib**<br>
187*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the TurboJPEG API
188*dfc6aa5cSAndroid Build Coastguard Worker
189*dfc6aa5cSAndroid Build Coastguard Worker**turbojpeg.dll**<br>
190*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the TurboJPEG API
191*dfc6aa5cSAndroid Build Coastguard Worker
192*dfc6aa5cSAndroid Build Coastguard Worker**turbojpeg.lib**<br>
193*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the TurboJPEG API
194*dfc6aa5cSAndroid Build Coastguard Worker
195*dfc6aa5cSAndroid Build Coastguard Worker*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
196*dfc6aa5cSAndroid Build Coastguard Workerv8 emulation is enabled.
197*dfc6aa5cSAndroid Build Coastguard Worker
198*dfc6aa5cSAndroid Build Coastguard Worker
199*dfc6aa5cSAndroid Build Coastguard Worker### Visual C++ (IDE)
200*dfc6aa5cSAndroid Build Coastguard Worker
201*dfc6aa5cSAndroid Build Coastguard WorkerChoose the appropriate CMake generator option for your version of Visual Studio
202*dfc6aa5cSAndroid Build Coastguard Worker(run `cmake` with no arguments for a list of available generators.)  For
203*dfc6aa5cSAndroid Build Coastguard Workerinstance:
204*dfc6aa5cSAndroid Build Coastguard Worker
205*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
206*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Visual Studio 10" [additional CMake flags] {source_directory}
207*dfc6aa5cSAndroid Build Coastguard Worker
208*dfc6aa5cSAndroid Build Coastguard WorkerNOTE: Add "Win64" to the generator name (for example, "Visual Studio 10 Win64")
209*dfc6aa5cSAndroid Build Coastguard Workerto build a 64-bit version of libjpeg-turbo.  A separate build directory must be
210*dfc6aa5cSAndroid Build Coastguard Workerused for 32-bit and 64-bit builds.
211*dfc6aa5cSAndroid Build Coastguard Worker
212*dfc6aa5cSAndroid Build Coastguard WorkerYou can then open **ALL_BUILD.vcproj** in Visual Studio and build one of the
213*dfc6aa5cSAndroid Build Coastguard Workerconfigurations in that project ("Debug", "Release", etc.) to generate a full
214*dfc6aa5cSAndroid Build Coastguard Workerbuild of libjpeg-turbo.
215*dfc6aa5cSAndroid Build Coastguard Worker
216*dfc6aa5cSAndroid Build Coastguard WorkerThis will generate the following files under *{build_directory}*:
217*dfc6aa5cSAndroid Build Coastguard Worker
218*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/jpeg-static.lib**<br>
219*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the libjpeg API
220*dfc6aa5cSAndroid Build Coastguard Worker
221*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/jpeg{version}.dll**<br>
222*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the libjpeg API
223*dfc6aa5cSAndroid Build Coastguard Worker
224*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/jpeg.lib**<br>
225*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the libjpeg API
226*dfc6aa5cSAndroid Build Coastguard Worker
227*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/turbojpeg-static.lib**<br>
228*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the TurboJPEG API
229*dfc6aa5cSAndroid Build Coastguard Worker
230*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/turbojpeg.dll**<br>
231*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the TurboJPEG API
232*dfc6aa5cSAndroid Build Coastguard Worker
233*dfc6aa5cSAndroid Build Coastguard Worker**{configuration}/turbojpeg.lib**<br>
234*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the TurboJPEG API
235*dfc6aa5cSAndroid Build Coastguard Worker
236*dfc6aa5cSAndroid Build Coastguard Worker*{configuration}* is Debug, Release, RelWithDebInfo, or MinSizeRel, depending
237*dfc6aa5cSAndroid Build Coastguard Workeron the configuration you built in the IDE, and *{version}* is 62, 7, or 8,
238*dfc6aa5cSAndroid Build Coastguard Workerdepending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
239*dfc6aa5cSAndroid Build Coastguard Worker
240*dfc6aa5cSAndroid Build Coastguard Worker
241*dfc6aa5cSAndroid Build Coastguard Worker### MinGW
242*dfc6aa5cSAndroid Build Coastguard Worker
243*dfc6aa5cSAndroid Build Coastguard WorkerNOTE: This assumes that you are building on a Windows machine using the MSYS
244*dfc6aa5cSAndroid Build Coastguard Workerenvironment.  If you are cross-compiling on a Un*x platform (including Mac and
245*dfc6aa5cSAndroid Build Coastguard WorkerCygwin), then see "Build Recipes" below.
246*dfc6aa5cSAndroid Build Coastguard Worker
247*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
248*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"MSYS Makefiles" [additional CMake flags] {source_directory}
249*dfc6aa5cSAndroid Build Coastguard Worker    make
250*dfc6aa5cSAndroid Build Coastguard Worker
251*dfc6aa5cSAndroid Build Coastguard WorkerThis will generate the following files under *{build_directory}*:
252*dfc6aa5cSAndroid Build Coastguard Worker
253*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.a**<br>
254*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the libjpeg API
255*dfc6aa5cSAndroid Build Coastguard Worker
256*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg-{version}.dll**<br>
257*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the libjpeg API
258*dfc6aa5cSAndroid Build Coastguard Worker
259*dfc6aa5cSAndroid Build Coastguard Worker**libjpeg.dll.a**<br>
260*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the libjpeg API
261*dfc6aa5cSAndroid Build Coastguard Worker
262*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.a**<br>
263*dfc6aa5cSAndroid Build Coastguard WorkerStatic link library for the TurboJPEG API
264*dfc6aa5cSAndroid Build Coastguard Worker
265*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.dll**<br>
266*dfc6aa5cSAndroid Build Coastguard WorkerDLL for the TurboJPEG API
267*dfc6aa5cSAndroid Build Coastguard Worker
268*dfc6aa5cSAndroid Build Coastguard Worker**libturbojpeg.dll.a**<br>
269*dfc6aa5cSAndroid Build Coastguard WorkerImport library for the TurboJPEG API
270*dfc6aa5cSAndroid Build Coastguard Worker
271*dfc6aa5cSAndroid Build Coastguard Worker*{version}* is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
272*dfc6aa5cSAndroid Build Coastguard Workerv8 emulation is enabled.
273*dfc6aa5cSAndroid Build Coastguard Worker
274*dfc6aa5cSAndroid Build Coastguard Worker
275*dfc6aa5cSAndroid Build Coastguard Worker### Debug Build
276*dfc6aa5cSAndroid Build Coastguard Worker
277*dfc6aa5cSAndroid Build Coastguard WorkerAdd `-DCMAKE_BUILD_TYPE=Debug` to the CMake command line.  Or, if building
278*dfc6aa5cSAndroid Build Coastguard Workerwith NMake, remove `-DCMAKE_BUILD_TYPE=Release` (Debug builds are the default
279*dfc6aa5cSAndroid Build Coastguard Workerwith NMake.)
280*dfc6aa5cSAndroid Build Coastguard Worker
281*dfc6aa5cSAndroid Build Coastguard Worker
282*dfc6aa5cSAndroid Build Coastguard Worker### libjpeg v7 or v8 API/ABI Emulation
283*dfc6aa5cSAndroid Build Coastguard Worker
284*dfc6aa5cSAndroid Build Coastguard WorkerAdd `-DWITH_JPEG7=1` to the CMake command line to build a version of
285*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add `-DWITH_JPEG8=1`
286*dfc6aa5cSAndroid Build Coastguard Workerto the CMake command line to build a version of libjpeg-turbo that is
287*dfc6aa5cSAndroid Build Coastguard WorkerAPI/ABI-compatible with libjpeg v8.  See [README.md](README.md) for more
288*dfc6aa5cSAndroid Build Coastguard Workerinformation about libjpeg v7 and v8 emulation.
289*dfc6aa5cSAndroid Build Coastguard Worker
290*dfc6aa5cSAndroid Build Coastguard Worker
291*dfc6aa5cSAndroid Build Coastguard Worker### In-Memory Source/Destination Managers
292*dfc6aa5cSAndroid Build Coastguard Worker
293*dfc6aa5cSAndroid Build Coastguard WorkerWhen using libjpeg v6b or v7 API/ABI emulation, add `-DWITH_MEM_SRCDST=0` to
294*dfc6aa5cSAndroid Build Coastguard Workerthe CMake command line to build a version of libjpeg-turbo that lacks the
295*dfc6aa5cSAndroid Build Coastguard Worker`jpeg_mem_src()` and `jpeg_mem_dest()` functions.  These functions were not
296*dfc6aa5cSAndroid Build Coastguard Workerpart of the original libjpeg v6b and v7 APIs, so removing them ensures strict
297*dfc6aa5cSAndroid Build Coastguard Workerconformance with those APIs.  See [README.md](README.md) for more information.
298*dfc6aa5cSAndroid Build Coastguard Worker
299*dfc6aa5cSAndroid Build Coastguard Worker
300*dfc6aa5cSAndroid Build Coastguard Worker### Arithmetic Coding Support
301*dfc6aa5cSAndroid Build Coastguard Worker
302*dfc6aa5cSAndroid Build Coastguard WorkerSince the patent on arithmetic coding has expired, this functionality has been
303*dfc6aa5cSAndroid Build Coastguard Workerincluded in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
304*dfc6aa5cSAndroid Build Coastguard Workerbased on the implementation in libjpeg v8, but it works when emulating libjpeg
305*dfc6aa5cSAndroid Build Coastguard Workerv7 or v6b as well.  The default is to enable both arithmetic encoding and
306*dfc6aa5cSAndroid Build Coastguard Workerdecoding, but those who have philosophical objections to arithmetic coding can
307*dfc6aa5cSAndroid Build Coastguard Workeradd `-DWITH_ARITH_ENC=0` or `-DWITH_ARITH_DEC=0` to the CMake command line to
308*dfc6aa5cSAndroid Build Coastguard Workerdisable encoding or decoding (respectively.)
309*dfc6aa5cSAndroid Build Coastguard Worker
310*dfc6aa5cSAndroid Build Coastguard Worker
311*dfc6aa5cSAndroid Build Coastguard Worker### TurboJPEG Java Wrapper
312*dfc6aa5cSAndroid Build Coastguard Worker
313*dfc6aa5cSAndroid Build Coastguard WorkerAdd `-DWITH_JAVA=1` to the CMake command line to incorporate an optional Java
314*dfc6aa5cSAndroid Build Coastguard WorkerNative Interface (JNI) wrapper into the TurboJPEG shared library and build the
315*dfc6aa5cSAndroid Build Coastguard WorkerJava front-end classes to support it.  This allows the TurboJPEG shared library
316*dfc6aa5cSAndroid Build Coastguard Workerto be used directly from Java applications.  See [java/README](java/README) for
317*dfc6aa5cSAndroid Build Coastguard Workermore details.
318*dfc6aa5cSAndroid Build Coastguard Worker
319*dfc6aa5cSAndroid Build Coastguard WorkerIf Java is not in your `PATH`, or if you wish to use an alternate JDK to
320*dfc6aa5cSAndroid Build Coastguard Workerbuild/test libjpeg-turbo, then (prior to running CMake) set the `JAVA_HOME`
321*dfc6aa5cSAndroid Build Coastguard Workerenvironment variable to the location of the JDK that you wish to use.  The
322*dfc6aa5cSAndroid Build Coastguard Worker`Java_JAVAC_EXECUTABLE`, `Java_JAVA_EXECUTABLE`, and `Java_JAR_EXECUTABLE`
323*dfc6aa5cSAndroid Build Coastguard WorkerCMake variables can also be used to specify alternate commands or locations for
324*dfc6aa5cSAndroid Build Coastguard Workerjavac, jar, and java (respectively.)  You can also set the
325*dfc6aa5cSAndroid Build Coastguard Worker`CMAKE_JAVA_COMPILE_FLAGS` CMake variable or the `JAVAFLAGS` environment
326*dfc6aa5cSAndroid Build Coastguard Workervariable to specify arguments that should be passed to the Java compiler when
327*dfc6aa5cSAndroid Build Coastguard Workerbuilding the TurboJPEG classes, and the `JAVAARGS` CMake variable to specify
328*dfc6aa5cSAndroid Build Coastguard Workerarguments that should be passed to the JRE when running the TurboJPEG Java unit
329*dfc6aa5cSAndroid Build Coastguard Workertests.
330*dfc6aa5cSAndroid Build Coastguard Worker
331*dfc6aa5cSAndroid Build Coastguard Worker
332*dfc6aa5cSAndroid Build Coastguard WorkerBuild Recipes
333*dfc6aa5cSAndroid Build Coastguard Worker-------------
334*dfc6aa5cSAndroid Build Coastguard Worker
335*dfc6aa5cSAndroid Build Coastguard Worker
336*dfc6aa5cSAndroid Build Coastguard Worker### 32-bit Build on 64-bit Linux/Unix
337*dfc6aa5cSAndroid Build Coastguard Worker
338*dfc6aa5cSAndroid Build Coastguard WorkerUse export/setenv to set the following environment variables before running
339*dfc6aa5cSAndroid Build Coastguard WorkerCMake:
340*dfc6aa5cSAndroid Build Coastguard Worker
341*dfc6aa5cSAndroid Build Coastguard Worker    CFLAGS=-m32
342*dfc6aa5cSAndroid Build Coastguard Worker    LDFLAGS=-m32
343*dfc6aa5cSAndroid Build Coastguard Worker
344*dfc6aa5cSAndroid Build Coastguard Worker
345*dfc6aa5cSAndroid Build Coastguard Worker### 64-bit Build on Solaris
346*dfc6aa5cSAndroid Build Coastguard Worker
347*dfc6aa5cSAndroid Build Coastguard WorkerUse export/setenv to set the following environment variables before running
348*dfc6aa5cSAndroid Build Coastguard WorkerCMake:
349*dfc6aa5cSAndroid Build Coastguard Worker
350*dfc6aa5cSAndroid Build Coastguard Worker    CFLAGS=-m64
351*dfc6aa5cSAndroid Build Coastguard Worker    LDFLAGS=-m64
352*dfc6aa5cSAndroid Build Coastguard Worker
353*dfc6aa5cSAndroid Build Coastguard Worker
354*dfc6aa5cSAndroid Build Coastguard Worker### Other Compilers
355*dfc6aa5cSAndroid Build Coastguard Worker
356*dfc6aa5cSAndroid Build Coastguard WorkerOn Un*x systems, prior to running CMake, you can set the `CC` environment
357*dfc6aa5cSAndroid Build Coastguard Workervariable to the command used to invoke the C compiler.
358*dfc6aa5cSAndroid Build Coastguard Worker
359*dfc6aa5cSAndroid Build Coastguard Worker
360*dfc6aa5cSAndroid Build Coastguard Worker### 32-bit MinGW Build on Un*x (including Mac and Cygwin)
361*dfc6aa5cSAndroid Build Coastguard Worker
362*dfc6aa5cSAndroid Build Coastguard WorkerCreate a file called **toolchain.cmake** under *{build_directory}*, with the
363*dfc6aa5cSAndroid Build Coastguard Workerfollowing contents:
364*dfc6aa5cSAndroid Build Coastguard Worker
365*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_NAME Windows)
366*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_PROCESSOR X86)
367*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_C_COMPILER {mingw_binary_path}/i686-w64-mingw32-gcc)
368*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_RC_COMPILER {mingw_binary_path}/i686-w64-mingw32-windres)
369*dfc6aa5cSAndroid Build Coastguard Worker
370*dfc6aa5cSAndroid Build Coastguard Worker*{mingw\_binary\_path}* is the directory under which the MinGW binaries are
371*dfc6aa5cSAndroid Build Coastguard Workerlocated (usually **/usr/bin**.)  Next, execute the following commands:
372*dfc6aa5cSAndroid Build Coastguard Worker
373*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
374*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
375*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_INSTALL_PREFIX={install_path} \
376*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
377*dfc6aa5cSAndroid Build Coastguard Worker    make
378*dfc6aa5cSAndroid Build Coastguard Worker
379*dfc6aa5cSAndroid Build Coastguard Worker*{install\_path}* is the path under which the libjpeg-turbo binaries should be
380*dfc6aa5cSAndroid Build Coastguard Workerinstalled.
381*dfc6aa5cSAndroid Build Coastguard Worker
382*dfc6aa5cSAndroid Build Coastguard Worker
383*dfc6aa5cSAndroid Build Coastguard Worker### 64-bit MinGW Build on Un*x (including Mac and Cygwin)
384*dfc6aa5cSAndroid Build Coastguard Worker
385*dfc6aa5cSAndroid Build Coastguard WorkerCreate a file called **toolchain.cmake** under *{build_directory}*, with the
386*dfc6aa5cSAndroid Build Coastguard Workerfollowing contents:
387*dfc6aa5cSAndroid Build Coastguard Worker
388*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_NAME Windows)
389*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_PROCESSOR AMD64)
390*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_C_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-gcc)
391*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_RC_COMPILER {mingw_binary_path}/x86_64-w64-mingw32-windres)
392*dfc6aa5cSAndroid Build Coastguard Worker
393*dfc6aa5cSAndroid Build Coastguard Worker*{mingw\_binary\_path}* is the directory under which the MinGW binaries are
394*dfc6aa5cSAndroid Build Coastguard Workerlocated (usually **/usr/bin**.)  Next, execute the following commands:
395*dfc6aa5cSAndroid Build Coastguard Worker
396*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
397*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
398*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_INSTALL_PREFIX={install_path} \
399*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
400*dfc6aa5cSAndroid Build Coastguard Worker    make
401*dfc6aa5cSAndroid Build Coastguard Worker
402*dfc6aa5cSAndroid Build Coastguard Worker*{install\_path}* is the path under which the libjpeg-turbo binaries should be
403*dfc6aa5cSAndroid Build Coastguard Workerinstalled.
404*dfc6aa5cSAndroid Build Coastguard Worker
405*dfc6aa5cSAndroid Build Coastguard Worker
406*dfc6aa5cSAndroid Build Coastguard WorkerBuilding libjpeg-turbo for iOS
407*dfc6aa5cSAndroid Build Coastguard Worker------------------------------
408*dfc6aa5cSAndroid Build Coastguard Worker
409*dfc6aa5cSAndroid Build Coastguard WorkeriOS platforms, such as the iPhone and iPad, use Arm processors, and all
410*dfc6aa5cSAndroid Build Coastguard Workercurrently supported models include Neon instructions.  Thus, they can take
411*dfc6aa5cSAndroid Build Coastguard Workeradvantage of libjpeg-turbo's SIMD extensions to significantly accelerate JPEG
412*dfc6aa5cSAndroid Build Coastguard Workercompression/decompression.  This section describes how to build libjpeg-turbo
413*dfc6aa5cSAndroid Build Coastguard Workerfor these platforms.
414*dfc6aa5cSAndroid Build Coastguard Worker
415*dfc6aa5cSAndroid Build Coastguard Worker
416*dfc6aa5cSAndroid Build Coastguard Worker### Armv8 (64-bit)
417*dfc6aa5cSAndroid Build Coastguard Worker
418*dfc6aa5cSAndroid Build Coastguard Worker**Xcode 5 or later required, Xcode 6.3.x or later recommended**
419*dfc6aa5cSAndroid Build Coastguard Worker
420*dfc6aa5cSAndroid Build Coastguard WorkerThe following script demonstrates how to build libjpeg-turbo to run on the
421*dfc6aa5cSAndroid Build Coastguard WorkeriPhone 5S/iPad Mini 2/iPad Air and newer.
422*dfc6aa5cSAndroid Build Coastguard Worker
423*dfc6aa5cSAndroid Build Coastguard Worker    IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
424*dfc6aa5cSAndroid Build Coastguard Worker    IOS_SYSROOT=($IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk)
425*dfc6aa5cSAndroid Build Coastguard Worker    export CFLAGS="-Wall -arch arm64 -miphoneos-version-min=8.0 -funwind-tables"
426*dfc6aa5cSAndroid Build Coastguard Worker
427*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
428*dfc6aa5cSAndroid Build Coastguard Worker
429*dfc6aa5cSAndroid Build Coastguard Worker    cat <<EOF >toolchain.cmake
430*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_NAME Darwin)
431*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_SYSTEM_PROCESSOR aarch64)
432*dfc6aa5cSAndroid Build Coastguard Worker    set(CMAKE_C_COMPILER /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang)
433*dfc6aa5cSAndroid Build Coastguard Worker    EOF
434*dfc6aa5cSAndroid Build Coastguard Worker
435*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
436*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_OSX_SYSROOT=${IOS_SYSROOT[0]} \
437*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
438*dfc6aa5cSAndroid Build Coastguard Worker    make
439*dfc6aa5cSAndroid Build Coastguard Worker
440*dfc6aa5cSAndroid Build Coastguard WorkerReplace `iPhoneOS` with `iPhoneSimulator` and `-miphoneos-version-min` with
441*dfc6aa5cSAndroid Build Coastguard Worker`-miphonesimulator-version-min` to build libjpeg-turbo for the iOS simulator on
442*dfc6aa5cSAndroid Build Coastguard WorkerMacs with Apple silicon CPUs.
443*dfc6aa5cSAndroid Build Coastguard Worker
444*dfc6aa5cSAndroid Build Coastguard Worker
445*dfc6aa5cSAndroid Build Coastguard WorkerBuilding libjpeg-turbo for Android
446*dfc6aa5cSAndroid Build Coastguard Worker----------------------------------
447*dfc6aa5cSAndroid Build Coastguard Worker
448*dfc6aa5cSAndroid Build Coastguard WorkerBuilding libjpeg-turbo for Android platforms requires v13b or later of the
449*dfc6aa5cSAndroid Build Coastguard Worker[Android NDK](https://developer.android.com/tools/sdk/ndk).
450*dfc6aa5cSAndroid Build Coastguard Worker
451*dfc6aa5cSAndroid Build Coastguard Worker
452*dfc6aa5cSAndroid Build Coastguard Worker### Armv7 (32-bit)
453*dfc6aa5cSAndroid Build Coastguard Worker
454*dfc6aa5cSAndroid Build Coastguard Worker**NDK r19 or later with Clang recommended**
455*dfc6aa5cSAndroid Build Coastguard Worker
456*dfc6aa5cSAndroid Build Coastguard WorkerThe following is a general recipe script that can be modified for your specific
457*dfc6aa5cSAndroid Build Coastguard Workerneeds.
458*dfc6aa5cSAndroid Build Coastguard Worker
459*dfc6aa5cSAndroid Build Coastguard Worker    # Set these variables to suit your needs
460*dfc6aa5cSAndroid Build Coastguard Worker    NDK_PATH={full path to the NDK directory-- for example,
461*dfc6aa5cSAndroid Build Coastguard Worker      /opt/android/android-ndk-r16b}
462*dfc6aa5cSAndroid Build Coastguard Worker    TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r16b and earlier,
463*dfc6aa5cSAndroid Build Coastguard Worker      and "clang" must be used with NDK r17c and later}
464*dfc6aa5cSAndroid Build Coastguard Worker    ANDROID_VERSION={the minimum version of Android to support-- for example,
465*dfc6aa5cSAndroid Build Coastguard Worker      "16", "19", etc.}
466*dfc6aa5cSAndroid Build Coastguard Worker
467*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
468*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" \
469*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ABI=armeabi-v7a \
470*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ARM_MODE=arm \
471*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
472*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
473*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_ASM_FLAGS="--target=arm-linux-androideabi${ANDROID_VERSION}" \
474*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
475*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
476*dfc6aa5cSAndroid Build Coastguard Worker    make
477*dfc6aa5cSAndroid Build Coastguard Worker
478*dfc6aa5cSAndroid Build Coastguard Worker
479*dfc6aa5cSAndroid Build Coastguard Worker### Armv8 (64-bit)
480*dfc6aa5cSAndroid Build Coastguard Worker
481*dfc6aa5cSAndroid Build Coastguard Worker**Clang recommended**
482*dfc6aa5cSAndroid Build Coastguard Worker
483*dfc6aa5cSAndroid Build Coastguard WorkerThe following is a general recipe script that can be modified for your specific
484*dfc6aa5cSAndroid Build Coastguard Workerneeds.
485*dfc6aa5cSAndroid Build Coastguard Worker
486*dfc6aa5cSAndroid Build Coastguard Worker    # Set these variables to suit your needs
487*dfc6aa5cSAndroid Build Coastguard Worker    NDK_PATH={full path to the NDK directory-- for example,
488*dfc6aa5cSAndroid Build Coastguard Worker      /opt/android/android-ndk-r16b}
489*dfc6aa5cSAndroid Build Coastguard Worker    TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
490*dfc6aa5cSAndroid Build Coastguard Worker      and "clang" must be used with NDK r17c and later}
491*dfc6aa5cSAndroid Build Coastguard Worker    ANDROID_VERSION={the minimum version of Android to support.  "21" or later
492*dfc6aa5cSAndroid Build Coastguard Worker      is required for a 64-bit build.}
493*dfc6aa5cSAndroid Build Coastguard Worker
494*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
495*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" \
496*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ABI=arm64-v8a \
497*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ARM_MODE=arm \
498*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
499*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
500*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_ASM_FLAGS="--target=aarch64-linux-android${ANDROID_VERSION}" \
501*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
502*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
503*dfc6aa5cSAndroid Build Coastguard Worker    make
504*dfc6aa5cSAndroid Build Coastguard Worker
505*dfc6aa5cSAndroid Build Coastguard Worker
506*dfc6aa5cSAndroid Build Coastguard Worker### x86 (32-bit)
507*dfc6aa5cSAndroid Build Coastguard Worker
508*dfc6aa5cSAndroid Build Coastguard WorkerThe following is a general recipe script that can be modified for your specific
509*dfc6aa5cSAndroid Build Coastguard Workerneeds.
510*dfc6aa5cSAndroid Build Coastguard Worker
511*dfc6aa5cSAndroid Build Coastguard Worker    # Set these variables to suit your needs
512*dfc6aa5cSAndroid Build Coastguard Worker    NDK_PATH={full path to the NDK directory-- for example,
513*dfc6aa5cSAndroid Build Coastguard Worker      /opt/android/android-ndk-r16b}
514*dfc6aa5cSAndroid Build Coastguard Worker    TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
515*dfc6aa5cSAndroid Build Coastguard Worker      and "clang" must be used with NDK r17c and later}
516*dfc6aa5cSAndroid Build Coastguard Worker    ANDROID_VERSION={The minimum version of Android to support-- for example,
517*dfc6aa5cSAndroid Build Coastguard Worker      "16", "19", etc.}
518*dfc6aa5cSAndroid Build Coastguard Worker
519*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
520*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" \
521*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ABI=x86 \
522*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
523*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
524*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
525*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
526*dfc6aa5cSAndroid Build Coastguard Worker    make
527*dfc6aa5cSAndroid Build Coastguard Worker
528*dfc6aa5cSAndroid Build Coastguard Worker
529*dfc6aa5cSAndroid Build Coastguard Worker### x86-64 (64-bit)
530*dfc6aa5cSAndroid Build Coastguard Worker
531*dfc6aa5cSAndroid Build Coastguard WorkerThe following is a general recipe script that can be modified for your specific
532*dfc6aa5cSAndroid Build Coastguard Workerneeds.
533*dfc6aa5cSAndroid Build Coastguard Worker
534*dfc6aa5cSAndroid Build Coastguard Worker    # Set these variables to suit your needs
535*dfc6aa5cSAndroid Build Coastguard Worker    NDK_PATH={full path to the NDK directory-- for example,
536*dfc6aa5cSAndroid Build Coastguard Worker      /opt/android/android-ndk-r16b}
537*dfc6aa5cSAndroid Build Coastguard Worker    TOOLCHAIN={"gcc" or "clang"-- "gcc" must be used with NDK r14b and earlier,
538*dfc6aa5cSAndroid Build Coastguard Worker      and "clang" must be used with NDK r17c and later}
539*dfc6aa5cSAndroid Build Coastguard Worker    ANDROID_VERSION={the minimum version of Android to support.  "21" or later
540*dfc6aa5cSAndroid Build Coastguard Worker      is required for a 64-bit build.}
541*dfc6aa5cSAndroid Build Coastguard Worker
542*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
543*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"Unix Makefiles" \
544*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_ABI=x86_64 \
545*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_PLATFORM=android-${ANDROID_VERSION} \
546*dfc6aa5cSAndroid Build Coastguard Worker      -DANDROID_TOOLCHAIN=${TOOLCHAIN} \
547*dfc6aa5cSAndroid Build Coastguard Worker      -DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
548*dfc6aa5cSAndroid Build Coastguard Worker      [additional CMake flags] {source_directory}
549*dfc6aa5cSAndroid Build Coastguard Worker    make
550*dfc6aa5cSAndroid Build Coastguard Worker
551*dfc6aa5cSAndroid Build Coastguard Worker
552*dfc6aa5cSAndroid Build Coastguard WorkerAdvanced CMake Options
553*dfc6aa5cSAndroid Build Coastguard Worker----------------------
554*dfc6aa5cSAndroid Build Coastguard Worker
555*dfc6aa5cSAndroid Build Coastguard WorkerTo list and configure other CMake options not specifically mentioned in this
556*dfc6aa5cSAndroid Build Coastguard Workerguide, run
557*dfc6aa5cSAndroid Build Coastguard Worker
558*dfc6aa5cSAndroid Build Coastguard Worker    ccmake {source_directory}
559*dfc6aa5cSAndroid Build Coastguard Worker
560*dfc6aa5cSAndroid Build Coastguard Workeror
561*dfc6aa5cSAndroid Build Coastguard Worker
562*dfc6aa5cSAndroid Build Coastguard Worker    cmake-gui {source_directory}
563*dfc6aa5cSAndroid Build Coastguard Worker
564*dfc6aa5cSAndroid Build Coastguard Workerfrom the build directory after initially configuring the build.  CCMake is a
565*dfc6aa5cSAndroid Build Coastguard Workertext-based interactive version of CMake, and CMake-GUI is a GUI version.  Both
566*dfc6aa5cSAndroid Build Coastguard Workerwill display all variables that are relevant to the libjpeg-turbo build, their
567*dfc6aa5cSAndroid Build Coastguard Workercurrent values, and a help string describing what they do.
568*dfc6aa5cSAndroid Build Coastguard Worker
569*dfc6aa5cSAndroid Build Coastguard Worker
570*dfc6aa5cSAndroid Build Coastguard WorkerInstalling libjpeg-turbo
571*dfc6aa5cSAndroid Build Coastguard Worker========================
572*dfc6aa5cSAndroid Build Coastguard Worker
573*dfc6aa5cSAndroid Build Coastguard WorkerYou can use the build system to install libjpeg-turbo (as opposed to creating
574*dfc6aa5cSAndroid Build Coastguard Workeran installer package.)  To do this, run `make install` or `nmake install`
575*dfc6aa5cSAndroid Build Coastguard Worker(or build the "install" target in the Visual Studio IDE.)  Running
576*dfc6aa5cSAndroid Build Coastguard Worker`make uninstall` or `nmake uninstall` (or building the "uninstall" target in
577*dfc6aa5cSAndroid Build Coastguard Workerthe Visual Studio IDE) will uninstall libjpeg-turbo.
578*dfc6aa5cSAndroid Build Coastguard Worker
579*dfc6aa5cSAndroid Build Coastguard WorkerThe `CMAKE_INSTALL_PREFIX` CMake variable can be modified in order to install
580*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg-turbo into a directory of your choosing.  If you don't specify
581*dfc6aa5cSAndroid Build Coastguard Worker`CMAKE_INSTALL_PREFIX`, then the default is:
582*dfc6aa5cSAndroid Build Coastguard Worker
583*dfc6aa5cSAndroid Build Coastguard Worker**c:\libjpeg-turbo**<br>
584*dfc6aa5cSAndroid Build Coastguard WorkerVisual Studio 32-bit build
585*dfc6aa5cSAndroid Build Coastguard Worker
586*dfc6aa5cSAndroid Build Coastguard Worker**c:\libjpeg-turbo64**<br>
587*dfc6aa5cSAndroid Build Coastguard WorkerVisual Studio 64-bit build
588*dfc6aa5cSAndroid Build Coastguard Worker
589*dfc6aa5cSAndroid Build Coastguard Worker**c:\libjpeg-turbo-gcc**<br>
590*dfc6aa5cSAndroid Build Coastguard WorkerMinGW 32-bit build
591*dfc6aa5cSAndroid Build Coastguard Worker
592*dfc6aa5cSAndroid Build Coastguard Worker**c:\libjpeg-turbo-gcc64**<br>
593*dfc6aa5cSAndroid Build Coastguard WorkerMinGW 64-bit build
594*dfc6aa5cSAndroid Build Coastguard Worker
595*dfc6aa5cSAndroid Build Coastguard Worker**/opt/libjpeg-turbo**<br>
596*dfc6aa5cSAndroid Build Coastguard WorkerUn*x
597*dfc6aa5cSAndroid Build Coastguard Worker
598*dfc6aa5cSAndroid Build Coastguard WorkerThe default value of `CMAKE_INSTALL_PREFIX` causes the libjpeg-turbo files to
599*dfc6aa5cSAndroid Build Coastguard Workerbe installed with a directory structure resembling that of the official
600*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg-turbo binary packages.  Changing the value of `CMAKE_INSTALL_PREFIX`
601*dfc6aa5cSAndroid Build Coastguard Worker(for instance, to **/usr/local**) causes the libjpeg-turbo files to be
602*dfc6aa5cSAndroid Build Coastguard Workerinstalled with a directory structure that conforms to GNU standards.
603*dfc6aa5cSAndroid Build Coastguard Worker
604*dfc6aa5cSAndroid Build Coastguard WorkerThe `CMAKE_INSTALL_BINDIR`, `CMAKE_INSTALL_DATAROOTDIR`,
605*dfc6aa5cSAndroid Build Coastguard Worker`CMAKE_INSTALL_DOCDIR`, `CMAKE_INSTALL_INCLUDEDIR`, `CMAKE_INSTALL_JAVADIR`,
606*dfc6aa5cSAndroid Build Coastguard Worker`CMAKE_INSTALL_LIBDIR`, and `CMAKE_INSTALL_MANDIR` CMake variables allow a
607*dfc6aa5cSAndroid Build Coastguard Workerfiner degree of control over where specific files in the libjpeg-turbo
608*dfc6aa5cSAndroid Build Coastguard Workerdistribution should be installed.  These directory variables can either be
609*dfc6aa5cSAndroid Build Coastguard Workerspecified as absolute paths or as paths relative to `CMAKE_INSTALL_PREFIX` (for
610*dfc6aa5cSAndroid Build Coastguard Workerinstance, setting `CMAKE_INSTALL_DOCDIR` to **doc** would cause the
611*dfc6aa5cSAndroid Build Coastguard Workerdocumentation to be installed in **${CMAKE\_INSTALL\_PREFIX}/doc**.)  If a
612*dfc6aa5cSAndroid Build Coastguard Workerdirectory variable contains the name of another directory variable in angle
613*dfc6aa5cSAndroid Build Coastguard Workerbrackets, then its final value will depend on the final value of that other
614*dfc6aa5cSAndroid Build Coastguard Workervariable.  For instance, the default value of `CMAKE_INSTALL_MANDIR` is
615*dfc6aa5cSAndroid Build Coastguard Worker**\<CMAKE\_INSTALL\_DATAROOTDIR\>/man**.
616*dfc6aa5cSAndroid Build Coastguard Worker
617*dfc6aa5cSAndroid Build Coastguard WorkerNOTE: If setting one of these directory variables to a relative path using the
618*dfc6aa5cSAndroid Build Coastguard WorkerCMake command line, you must specify that the variable is of type `PATH`.
619*dfc6aa5cSAndroid Build Coastguard WorkerFor example:
620*dfc6aa5cSAndroid Build Coastguard Worker
621*dfc6aa5cSAndroid Build Coastguard Worker    cmake -G"{generator type}" -DCMAKE_INSTALL_LIBDIR:PATH=lib {source_directory}
622*dfc6aa5cSAndroid Build Coastguard Worker
623*dfc6aa5cSAndroid Build Coastguard WorkerOtherwise, CMake will assume that the path is relative to the build directory
624*dfc6aa5cSAndroid Build Coastguard Workerrather than the install directory.
625*dfc6aa5cSAndroid Build Coastguard Worker
626*dfc6aa5cSAndroid Build Coastguard Worker
627*dfc6aa5cSAndroid Build Coastguard WorkerCreating Distribution Packages
628*dfc6aa5cSAndroid Build Coastguard Worker==============================
629*dfc6aa5cSAndroid Build Coastguard Worker
630*dfc6aa5cSAndroid Build Coastguard WorkerThe following commands can be used to create various types of distribution
631*dfc6aa5cSAndroid Build Coastguard Workerpackages:
632*dfc6aa5cSAndroid Build Coastguard Worker
633*dfc6aa5cSAndroid Build Coastguard Worker
634*dfc6aa5cSAndroid Build Coastguard WorkerLinux
635*dfc6aa5cSAndroid Build Coastguard Worker-----
636*dfc6aa5cSAndroid Build Coastguard Worker
637*dfc6aa5cSAndroid Build Coastguard Worker    make rpm
638*dfc6aa5cSAndroid Build Coastguard Worker
639*dfc6aa5cSAndroid Build Coastguard WorkerCreate Red Hat-style binary RPM package.  Requires RPM v4 or later.
640*dfc6aa5cSAndroid Build Coastguard Worker
641*dfc6aa5cSAndroid Build Coastguard Worker    make srpm
642*dfc6aa5cSAndroid Build Coastguard Worker
643*dfc6aa5cSAndroid Build Coastguard WorkerThis runs `make dist` to create a pristine source tarball, then creates a
644*dfc6aa5cSAndroid Build Coastguard WorkerRed Hat-style source RPM package from the tarball.  Requires RPM v4 or later.
645*dfc6aa5cSAndroid Build Coastguard Worker
646*dfc6aa5cSAndroid Build Coastguard Worker    make deb
647*dfc6aa5cSAndroid Build Coastguard Worker
648*dfc6aa5cSAndroid Build Coastguard WorkerCreate Debian-style binary package.  Requires dpkg.
649*dfc6aa5cSAndroid Build Coastguard Worker
650*dfc6aa5cSAndroid Build Coastguard Worker
651*dfc6aa5cSAndroid Build Coastguard WorkerMac
652*dfc6aa5cSAndroid Build Coastguard Worker---
653*dfc6aa5cSAndroid Build Coastguard Worker
654*dfc6aa5cSAndroid Build Coastguard Worker    make dmg
655*dfc6aa5cSAndroid Build Coastguard Worker
656*dfc6aa5cSAndroid Build Coastguard WorkerCreate Mac package/disk image.  This requires pkgbuild and productbuild, which
657*dfc6aa5cSAndroid Build Coastguard Workerare installed by default on OS X/macOS 10.7 and later.
658*dfc6aa5cSAndroid Build Coastguard Worker
659*dfc6aa5cSAndroid Build Coastguard WorkerIn order to create a Mac package/disk image that contains universal
660*dfc6aa5cSAndroid Build Coastguard Workerx86-64/Arm binaries, set the following CMake variable:
661*dfc6aa5cSAndroid Build Coastguard Worker
662*dfc6aa5cSAndroid Build Coastguard Worker* `ARMV8_BUILD`: Directory containing an Armv8 (64-bit) iOS or macOS build of
663*dfc6aa5cSAndroid Build Coastguard Worker  libjpeg-turbo to include in the universal binaries
664*dfc6aa5cSAndroid Build Coastguard Worker
665*dfc6aa5cSAndroid Build Coastguard WorkerYou should first use CMake to configure an Armv8 sub-build of libjpeg-turbo
666*dfc6aa5cSAndroid Build Coastguard Worker(see "Building libjpeg-turbo for iOS" above, if applicable) in a build
667*dfc6aa5cSAndroid Build Coastguard Workerdirectory that matches the one specified in the aforementioned CMake variable.
668*dfc6aa5cSAndroid Build Coastguard WorkerNext, configure the primary (x86-64) build of libjpeg-turbo as an out-of-tree
669*dfc6aa5cSAndroid Build Coastguard Workerbuild, specifying the aforementioned CMake variable, and build it.  Once the
670*dfc6aa5cSAndroid Build Coastguard Workerprimary build has been built, run `make dmg` from the build directory.  The
671*dfc6aa5cSAndroid Build Coastguard Workerpackaging system will build the sub-build, use lipo to combine it with the
672*dfc6aa5cSAndroid Build Coastguard Workerprimary build into a single set of universal binaries, then package the
673*dfc6aa5cSAndroid Build Coastguard Workeruniversal binaries.
674*dfc6aa5cSAndroid Build Coastguard Worker
675*dfc6aa5cSAndroid Build Coastguard Worker
676*dfc6aa5cSAndroid Build Coastguard WorkerWindows
677*dfc6aa5cSAndroid Build Coastguard Worker-------
678*dfc6aa5cSAndroid Build Coastguard Worker
679*dfc6aa5cSAndroid Build Coastguard WorkerIf using NMake:
680*dfc6aa5cSAndroid Build Coastguard Worker
681*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
682*dfc6aa5cSAndroid Build Coastguard Worker    nmake installer
683*dfc6aa5cSAndroid Build Coastguard Worker
684*dfc6aa5cSAndroid Build Coastguard WorkerIf using MinGW:
685*dfc6aa5cSAndroid Build Coastguard Worker
686*dfc6aa5cSAndroid Build Coastguard Worker    cd {build_directory}
687*dfc6aa5cSAndroid Build Coastguard Worker    make installer
688*dfc6aa5cSAndroid Build Coastguard Worker
689*dfc6aa5cSAndroid Build Coastguard WorkerIf using the Visual Studio IDE, build the "installer" target.
690*dfc6aa5cSAndroid Build Coastguard Worker
691*dfc6aa5cSAndroid Build Coastguard WorkerThe installer package (libjpeg-turbo-*{version}*[-gcc|-vc][64].exe) will be
692*dfc6aa5cSAndroid Build Coastguard Workerlocated under *{build_directory}*.  If building using the Visual Studio IDE,
693*dfc6aa5cSAndroid Build Coastguard Workerthen the installer package will be located in a subdirectory with the same name
694*dfc6aa5cSAndroid Build Coastguard Workeras the configuration you built (such as *{build_directory}*\Debug\ or
695*dfc6aa5cSAndroid Build Coastguard Worker*{build_directory}*\Release\).
696*dfc6aa5cSAndroid Build Coastguard Worker
697*dfc6aa5cSAndroid Build Coastguard WorkerBuilding a Windows installer requires the
698*dfc6aa5cSAndroid Build Coastguard Worker[Nullsoft Install System](http://nsis.sourceforge.net/).  makensis.exe should
699*dfc6aa5cSAndroid Build Coastguard Workerbe in your `PATH`.
700*dfc6aa5cSAndroid Build Coastguard Worker
701*dfc6aa5cSAndroid Build Coastguard Worker
702*dfc6aa5cSAndroid Build Coastguard WorkerRegression testing
703*dfc6aa5cSAndroid Build Coastguard Worker==================
704*dfc6aa5cSAndroid Build Coastguard Worker
705*dfc6aa5cSAndroid Build Coastguard WorkerThe most common way to test libjpeg-turbo is by invoking `make test` (Un*x) or
706*dfc6aa5cSAndroid Build Coastguard Worker`nmake test` (Windows command line) or by building the "RUN_TESTS" target
707*dfc6aa5cSAndroid Build Coastguard Worker(Visual Studio IDE), once the build has completed.  This runs a series of tests
708*dfc6aa5cSAndroid Build Coastguard Workerto ensure that mathematical compatibility has been maintained between
709*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg-turbo and libjpeg v6b.  This also invokes the TurboJPEG unit tests,
710*dfc6aa5cSAndroid Build Coastguard Workerwhich ensure that the colorspace extensions, YUV encoding, decompression
711*dfc6aa5cSAndroid Build Coastguard Workerscaling, and other features of the TurboJPEG C and Java APIs are working
712*dfc6aa5cSAndroid Build Coastguard Workerproperly (and, by extension, that the equivalent features of the underlying
713*dfc6aa5cSAndroid Build Coastguard Workerlibjpeg API are also working.)
714*dfc6aa5cSAndroid Build Coastguard Worker
715*dfc6aa5cSAndroid Build Coastguard WorkerInvoking `make testclean` (Un*x) or `nmake testclean` (Windows command line) or
716*dfc6aa5cSAndroid Build Coastguard Workerbuilding the "testclean" target (Visual Studio IDE) will clean up the output
717*dfc6aa5cSAndroid Build Coastguard Workerimages generated by the tests.
718*dfc6aa5cSAndroid Build Coastguard Worker
719*dfc6aa5cSAndroid Build Coastguard WorkerOn Un*x platforms, more extensive tests of the TurboJPEG C and Java wrappers
720*dfc6aa5cSAndroid Build Coastguard Workercan be run by invoking `make tjtest`.  These extended TurboJPEG tests
721*dfc6aa5cSAndroid Build Coastguard Workeressentially iterate through all of the available features of the TurboJPEG APIs
722*dfc6aa5cSAndroid Build Coastguard Workerthat are not covered by the TurboJPEG unit tests (including the lossless
723*dfc6aa5cSAndroid Build Coastguard Workertransform options) and compare the images generated by each feature to images
724*dfc6aa5cSAndroid Build Coastguard Workergenerated using the equivalent feature in the libjpeg API.  The extended
725*dfc6aa5cSAndroid Build Coastguard WorkerTurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
726*dfc6aa5cSAndroid Build Coastguard Workernot in the underlying libjpeg API library.
727