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