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