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