1*******************************************************************************
2**     Building on Un*x Platforms (including Cygwin and OS X)
3*******************************************************************************
4
5
6==================
7Build Requirements
8==================
9
10-- autoconf 2.56 or later
11-- automake 1.7 or later
12-- libtool 1.4 or later
13   * If using Xcode 4.3 or later on OS X, autoconf and automake are no longer
14     provided.  The easiest way to obtain them is from MacPorts
15     (http://www.macports.org/).
16
17-- NASM or YASM (if building x86 or x86-64 SIMD extensions)
18   * NASM 0.98, or 2.01 or later is required for an x86 build (0.99 and 2.00 do
19     not work properly with libjpeg-turbo's x86 SIMD code.)
20   * NASM 2.00 or later is required for an x86-64 build.
21   * NASM 2.07, or 2.11.09 or later is required for an x86-64 Mac build
22     (2.11.08 does not work properly with libjpeg-turbo's x86-64 SIMD code when
23     building macho64 objects.)  NASM or YASM can be obtained from MacPorts
24     (http://www.macports.org/).
25
26   The binary RPMs released by the NASM project do not work on older Linux
27   systems, such as Red Hat Enterprise Linux 4.  On such systems, you can
28   easily build and install NASM from a source RPM by downloading one of the
29   SRPMs from
30
31   http://www.nasm.us/pub/nasm/releasebuilds
32
33   and executing the following as root:
34
35     ARCH=`uname -m`
36     rpmbuild --rebuild nasm-{version}.src.rpm
37     rpm -Uvh /usr/src/redhat/RPMS/$ARCH/nasm-{version}.$ARCH.rpm
38
39   NOTE: the NASM build will fail if texinfo is not installed.
40
41-- GCC v4.1 or later recommended for best performance
42   * Beginning with Xcode 4, Apple stopped distributing GCC and switched to
43     the LLVM compiler.  Xcode v4.0 through v4.6 provides a GCC front end
44     called LLVM-GCC.  Unfortunately, as of this writing, neither LLVM-GCC nor
45     the LLVM (clang) compiler produces optimal performance with libjpeg-turbo.
46     Building libjpeg-turbo with LLVM-GCC v4.2 results in a 10% performance
47     degradation when compressing using 64-bit code, relative to building
48     libjpeg-turbo with GCC v4.2.  Building libjpeg-turbo with LLVM (clang)
49     results in a 20% performance degradation when compressing using 64-bit
50     code, relative to building libjpeg-turbo with GCC v4.2.  If you are
51     running Snow Leopard or earlier, it is suggested that you continue to use
52     Xcode v3.2.6, which provides GCC v4.2.  If you are using Lion or later, it
53     is suggested that you install Apple GCC v4.2 or GCC v5 through MacPorts.
54
55-- If building the TurboJPEG Java wrapper, JDK or OpenJDK 1.5 or later is
56   required.  Some systems, such as Solaris 10 and later and Red Hat Enterprise
57   Linux 5 and later, have this pre-installed.  On OS X 10.5 and later, it will
58   be necessary to install the Java Developer Package, which can be downloaded
59   from http://developer.apple.com/downloads (Apple ID required.)  For systems
60   that do not have a JDK installed, you can obtain the Oracle Java Development
61   Kit from http://www.java.com.
62
63
64==================
65Out-of-Tree Builds
66==================
67
68Binary objects, libraries, and executables are generated in the same directory
69from which configure was executed (the "binary directory"), and this directory
70need not necessarily be the same as the libjpeg-turbo source directory.  You
71can create multiple independent binary directories, in which different versions
72of libjpeg-turbo can be built from the same source tree using different
73compilers or settings.  In the sections below, {build_directory} refers to the
74binary directory, whereas {source_directory} refers to the libjpeg-turbo source
75directory.  For in-tree builds, these directories are the same.
76
77
78======================
79Building libjpeg-turbo
80======================
81
82The following procedure will build libjpeg-turbo on Linux, FreeBSD, Cygwin, and
83Solaris/x86 systems (on Solaris, this generates a 32-bit library.  See below
84for 64-bit build instructions.)
85
86  cd {source_directory}
87  autoreconf -fiv
88  cd {build_directory}
89  sh {source_directory}/configure [additional configure flags]
90  make
91
92NOTE: Running autoreconf in the source directory is usually only necessary if
93building libjpeg-turbo from the SVN repository.
94
95This will generate the following files under .libs/
96
97  libjpeg.a
98      Static link library for the libjpeg API
99
100  libjpeg.so.{version} (Linux, Unix)
101  libjpeg.{version}.dylib (OS X)
102  cygjpeg-{version}.dll (Cygwin)
103      Shared library for the libjpeg API
104
105  By default, {version} is 62.1.0, 7.1.0, or 8.0.2, depending on whether
106  libjpeg v6b (default), v7, or v8 emulation is enabled.  If using Cygwin,
107  {version} is 62, 7, or 8.
108
109  libjpeg.so (Linux, Unix)
110  libjpeg.dylib (OS X)
111      Development symlink for the libjpeg API
112
113  libjpeg.dll.a (Cygwin)
114      Import library for the libjpeg API
115
116  libturbojpeg.a
117      Static link library for the TurboJPEG API
118
119  libturbojpeg.so.0.1.0 (Linux, Unix)
120  libturbojpeg.0.1.0.dylib (OS X)
121  cygturbojpeg-0.dll (Cygwin)
122      Shared library for the TurboJPEG API
123
124  libturbojpeg.so (Linux, Unix)
125  libturbojpeg.dylib (OS X)
126      Development symlink for the TurboJPEG API
127
128  libturbojpeg.dll.a (Cygwin)
129      Import library for the TurboJPEG API
130
131
132libjpeg v7 or v8 API/ABI Emulation
133----------------------------------
134
135Add --with-jpeg7 to the configure command line to build a version of
136libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add --with-jpeg8 to
137the configure command to build a version of libjpeg-turbo that is
138API/ABI-compatible with libjpeg v8.  See README-turbo.txt for more information
139on libjpeg v7 and v8 emulation.
140
141
142In-Memory Source/Destination Managers
143-------------------------------------
144
145When using libjpeg v6b or v7 API/ABI emulation, add --without-mem-srcdst to the
146configure command line to build a version of libjpeg-turbo that lacks the
147jpeg_mem_src() and jpeg_mem_dest() functions.  These functions were not part of
148the original libjpeg v6b and v7 APIs, so removing them ensures strict
149conformance with those APIs.  See README-turbo.txt for more information.
150
151
152Arithmetic Coding Support
153-------------------------
154
155Since the patent on arithmetic coding has expired, this functionality has been
156included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
157based on the implementation in libjpeg v8, but it works when emulating libjpeg
158v7 or v6b as well.  The default is to enable both arithmetic encoding and
159decoding, but those who have philosophical objections to arithmetic coding can
160add --without-arith-enc or --without-arith-dec to the configure command line to
161disable encoding or decoding (respectively.)
162
163
164TurboJPEG Java Wrapper
165----------------------
166Add --with-java to the configure command line to incorporate an optional Java
167Native Interface wrapper into the TurboJPEG shared library and build the Java
168front-end classes to support it.  This allows the TurboJPEG shared library to
169be used directly from Java applications.  See java/README for more details.
170
171You can set the JAVAC, JAR, and JAVA configure variables to specify
172alternate commands for javac, jar, and java (respectively.)  You can also
173set the JAVACFLAGS configure variable to specify arguments that should be
174passed to the Java compiler when building the front-end classes, and JNI_CFLAGS
175to specify arguments that should be passed to the C compiler when building the
176JNI wrapper.  Run 'configure --help' for more details.
177
178
179========================
180Installing libjpeg-turbo
181========================
182
183If you intend to install these libraries and the associated header files, then
184replace 'make' in the instructions above with
185
186  make install prefix={base dir} libdir={library directory}
187
188For example,
189
190  make install prefix=/usr/local libdir=/usr/local/lib64
191
192will install the header files in /usr/local/include and the library files in
193/usr/local/lib64.  If 'prefix' and 'libdir' are not specified, then the default
194is to install the header files in /opt/libjpeg-turbo/include and the library
195files in /opt/libjpeg-turbo/lib32 (32-bit) or /opt/libjpeg-turbo/lib64
196(64-bit.)
197
198NOTE: You can specify a prefix of /usr and a libdir of, for instance,
199/usr/lib64 to overwrite the system's version of libjpeg.  If you do this,
200however, then be sure to BACK UP YOUR SYSTEM'S INSTALLATION OF LIBJPEG before
201overwriting it.  It is recommended that you instead install libjpeg-turbo into
202a non-system directory and manipulate the LD_LIBRARY_PATH or create symlinks
203to force applications to use libjpeg-turbo instead of libjpeg.  See
204README-turbo.txt for more information.
205
206
207=============
208Build Recipes
209=============
210
211
21232-bit Build on 64-bit Linux
213----------------------------
214
215Add
216
217  --host i686-pc-linux-gnu CFLAGS='-O3 -m32' LDFLAGS=-m32
218
219to the configure command line.
220
221
22264-bit Build on 64-bit OS X
223---------------------------
224
225Add
226
227  --host x86_64-apple-darwin NASM=/opt/local/bin/nasm
228
229to the configure command line.  NASM 2.07 or later from MacPorts must be
230installed.
231
232
23332-bit Build on 64-bit OS X
234---------------------------
235
236Add
237
238  --host i686-apple-darwin CFLAGS='-O3 -m32' LDFLAGS=-m32
239
240to the configure command line.
241
242
24364-bit Backward-Compatible Build on 64-bit OS X
244-----------------------------------------------
245
246Add
247
248  --host x86_64-apple-darwin NASM=/opt/local/bin/nasm \
249  CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
250    -mmacosx-version-min=10.5 -O3' \
251    LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
252    -mmacosx-version-min=10.5'
253
254to the configure command line.  The OS X 10.5 SDK, and NASM 2.07 or later from
255MacPorts, must be installed.
256
257
25832-bit Backward-Compatible Build on OS X
259----------------------------------------
260
261Add
262
263  --host i686-apple-darwin \
264    CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
265    -mmacosx-version-min=10.5 -O3 -m32' \
266    LDFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk \
267    -mmacosx-version-min=10.5 -m32'
268
269to the configure command line.  The OS X 10.5 SDK must be installed.
270
271
27264-bit Library Build on 64-bit Solaris
273--------------------------------------
274
275Add
276
277  --host x86_64-pc-solaris CFLAGS='-O3 -m64' LDFLAGS=-m64
278
279to the configure command line.
280
281
28232-bit Build on 64-bit FreeBSD
283------------------------------
284
285Add
286
287  --host i386-unknown-freebsd CC='gcc -B /usr/lib32' CFLAGS='-O3 -m32' \
288    LDFLAGS='-B/usr/lib32'
289
290to the configure command line.  NASM 2.07 or later from FreeBSD ports must be
291installed.
292
293
294Oracle Solaris Studio
295---------------------
296
297Add
298
299  CC=cc
300
301to the configure command line.  libjpeg-turbo will automatically be built with
302the maximum optimization level (-xO5) unless you override CFLAGS.
303
304To build a 64-bit version of libjpeg-turbo using Oracle Solaris Studio, add
305
306  --host x86_64-pc-solaris CC=cc CFLAGS='-xO5 -m64' LDFLAGS=-m64
307
308to the configure command line.
309
310
311MinGW Build on Cygwin
312---------------------
313
314Use CMake (see recipes below)
315
316
317===========
318ARM Support
319===========
320
321This release of libjpeg-turbo can use ARM NEON SIMD instructions to accelerate
322JPEG compression/decompression by approximately 2-4x on ARMv7 and later
323platforms.  If libjpeg-turbo is configured on an ARM Linux platform, then the
324build system will automatically include the NEON SIMD routines, if they are
325supported.  Build instructions for other ARM-based platforms follow.
326
327
328Building libjpeg-turbo for iOS
329------------------------------
330
331iOS platforms, such as the iPhone and iPad, use ARM processors, some of which
332support NEON instructions.  Additional steps are required in order to build
333libjpeg-turbo for these platforms.
334
335Additional build requirements:
336
337  gas-preprocessor.pl
338  (https://raw.githubusercontent.com/libjpeg-turbo/gas-preprocessor/master/gas-preprocessor.pl)
339  should be installed in your PATH.
340
341
342ARM 32-bit Build (Xcode 4.6.x and earlier, LLVM-GCC):
343
344Set the following shell variables for simplicity:
345
346  Xcode 4.2 and earlier:
347  IOS_PLATFORMDIR=/Developer/Platforms/iPhoneOS.platform
348  Xcode 4.3 and later:
349  IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
350
351  IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
352  IOS_GCC=$IOS_PLATFORMDIR/Developer/usr/bin/arm-apple-darwin10-llvm-gcc-4.2
353
354  ARMv6 (code will run on all iOS devices, not SIMD-accelerated):
355  [NOTE: Requires Xcode 4.4.x or earlier]
356  IOS_CFLAGS="-march=armv6 -mcpu=arm1176jzf-s -mfpu=vfp"
357
358  ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
359  IOS_CFLAGS="-march=armv7 -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon"
360
361  ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
362  [NOTE: Requires Xcode 4.5 or later]
363  IOS_CFLAGS="-march=armv7s -mcpu=swift -mtune=swift -mfpu=neon"
364
365Follow the procedure under "Building libjpeg-turbo" above, adding
366
367  --host arm-apple-darwin10 \
368    CC="$IOS_GCC" LD="$IOS_GCC" \
369    CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
370    LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS"
371
372to the configure command line.
373
374
375ARM 32-bit Build (Xcode 5.0.x and later, Clang):
376
377Set the following shell variables for simplicity:
378
379  IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
380  IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
381  IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
382
383  ARMv7 (code will run on iPhone 3GS-4S/iPad 1st-3rd Generation and newer):
384  IOS_CFLAGS="-arch armv7"
385
386  ARMv7s (code will run on iPhone 5/iPad 4th Generation and newer):
387  IOS_CFLAGS="-arch armv7s"
388
389Follow the procedure under "Building libjpeg-turbo" above, adding
390
391  --host arm-apple-darwin10 \
392    CC="$IOS_GCC" LD="$IOS_GCC" \
393    CFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
394    LDFLAGS="-mfloat-abi=softfp -isysroot $IOS_SYSROOT $IOS_CFLAGS" \
395    CCASFLAGS="-no-integrated-as $IOS_CFLAGS"
396
397to the configure command line.
398
399
400ARMv8 64-bit Build (Xcode 5.0.x and later, Clang):
401
402Code will run on iPhone 5S/iPad Mini 2/iPad Air and newer.
403
404Set the following shell variables for simplicity:
405
406  IOS_PLATFORMDIR=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
407  IOS_SYSROOT=$IOS_PLATFORMDIR/Developer/SDKs/iPhoneOS*.sdk
408  IOS_GCC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
409  IOS_CFLAGS="-arch arm64"
410
411Follow the procedure under "Building libjpeg-turbo" above, adding
412
413  --host aarch64-apple-darwin \
414    CC="$IOS_GCC" LD="$IOS_GCC" \
415    CFLAGS="-isysroot $IOS_SYSROOT -O3 $IOS_CFLAGS" \
416    LDFLAGS="-isysroot $IOS_SYSROOT $IOS_CFLAGS"
417
418to the configure command line.
419
420
421NOTE:  You can also add -miphoneos-version-min={version} to $IOS_CFLAGS above
422in order to support older versions of iOS than the default version supported by
423the SDK.
424
425Once built, lipo can be used to combine the ARMv6, v7, v7s, and/or v8 variants
426into a universal library.
427
428NOTE: If you are building libjpeg-turbo from the "official" project tarball,
429then it is highly likely that you will need to run 'autoreconf -fiv' in the
430source tree prior to building ARMv7, v7s, or v8 iOS binaries using the
431techniques described above.  Otherwise, you may get a libtool error such as
432"unable to infer tagged configuration."
433
434
435Building libjpeg-turbo for Android
436----------------------------------
437
438Building libjpeg-turbo for Android platforms requires the Android NDK
439(https://developer.android.com/tools/sdk/ndk) and autotools.  The following is
440a general recipe script that can be modified for your specific needs.
441
442  # Set these variables to suit your needs
443  NDK_PATH={full path to the "ndk" directory-- for example, /opt/android/ndk}
444  BUILD_PLATFORM={the platform name for the NDK package you installed--
445    for example, "windows-x86" or "linux-x86_64"}
446  TOOLCHAIN_VERSION={"4.6", "4.8", etc.  This corresponds to a toolchain
447    directory under ${NDK_PATH}/toolchains/.}
448  ANDROID_VERSION={The minimum version of Android to support-- for example,
449    "9", "19", etc.}
450
451  HOST=arm-linux-androideabi
452  TOOLCHAIN=${NDK_PATH}/toolchains/${HOST}-${TOOLCHAIN_VERSION}/prebuilt/${BUILD_PLATFORM}
453  SYSROOT=${NDK_PATH}/platforms/android-${ANDROID_VERSION}/arch-arm
454  ANDROID_INCLUDES="-I${SYSROOT}/usr/include -I${TOOLCHAIN}/include"
455  ANDROID_CFLAGS="-march=armv7-a -mfloat-abi=softfp -fprefetch-loop-arrays \
456    -fstrict-aliasing --sysroot=${SYSROOT}"
457  export CPP=${TOOLCHAIN}/bin/${HOST}-cpp
458  export AR=${TOOLCHAIN}/bin/${HOST}-ar
459  export AS=${TOOLCHAIN}/bin/${HOST}-as
460  export NM=${TOOLCHAIN}/bin/${HOST}-nm
461  export CC=${TOOLCHAIN}/bin/${HOST}-gcc
462  export LD=${TOOLCHAIN}/bin/${HOST}-ld
463  export RANLIB=${TOOLCHAIN}/bin/${HOST}-ranlib
464  export OBJDUMP=${TOOLCHAIN}/bin/${HOST}-objdump
465  export STRIP=${TOOLCHAIN}/bin/${HOST}-strip
466  cd {build_directory}
467  sh {source_directory}/configure --host=${HOST} \
468    CFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS} -O3" \
469    CPPFLAGS="${ANDROID_INCLUDES} ${ANDROID_CFLAGS}" \
470    LDFLAGS="${ANDROID_CFLAGS}" --with-simd ${1+"$@"}
471  make
472
473
474*******************************************************************************
475**     Building on Windows (Visual C++ or MinGW)
476*******************************************************************************
477
478
479==================
480Build Requirements
481==================
482
483-- CMake (http://www.cmake.org) v2.8.8 or later
484
485-- Microsoft Visual C++ 2005 or later
486
487   If you don't already have Visual C++, then the easiest way to get it is by
488   installing the Windows SDK:
489
490   http://msdn.microsoft.com/en-us/windows/bb980924.aspx
491
492   The Windows SDK includes both 32-bit and 64-bit Visual C++ compilers and
493   everything necessary to build libjpeg-turbo.
494
495   * You can also use Microsoft Visual Studio Express Edition, which is a free
496     download.  (NOTE: versions prior to 2012 can only be used to build 32-bit
497     code.)
498   * If you intend to build libjpeg-turbo from the command line, then add the
499     appropriate compiler and SDK directories to the INCLUDE, LIB, and PATH
500     environment variables.  This is generally accomplished by executing
501     vcvars32.bat or vcvars64.bat and SetEnv.cmd.  vcvars32.bat and
502     vcvars64.bat are part of Visual C++ and are located in the same directory
503     as the compiler.  SetEnv.cmd is part of the Windows SDK.  You can pass
504     optional arguments to SetEnv.cmd to specify a 32-bit or 64-bit build
505     environment.
506
507... OR ...
508
509-- MinGW
510
511   MinGW-builds (http://sourceforge.net/projects/mingwbuilds/) or
512   tdm-gcc (http://tdm-gcc.tdragon.net/) recommended if building on a Windows
513   machine.  Both distributions install a Start Menu link that can be used to
514   launch a command prompt with the appropriate compiler paths automatically
515   set.
516
517-- NASM (http://www.nasm.us/) 0.98 or later (NASM 2.05 or later is required for
518   a 64-bit build)
519
520-- If building the TurboJPEG Java wrapper, JDK 1.5 or later is required.  This
521   can be downloaded from http://www.java.com.
522
523
524==================
525Out-of-Tree Builds
526==================
527
528Binary objects, libraries, and executables are generated in the same directory
529from which cmake was executed (the "binary directory"), and this directory need
530not necessarily be the same as the libjpeg-turbo source directory.  You can
531create multiple independent binary directories, in which different versions of
532libjpeg-turbo can be built from the same source tree using different compilers
533or settings.  In the sections below, {build_directory} refers to the binary
534directory, whereas {source_directory} refers to the libjpeg-turbo source
535directory.  For in-tree builds, these directories are the same.
536
537
538======================
539Building libjpeg-turbo
540======================
541
542
543Visual C++ (Command Line)
544-------------------------
545
546  cd {build_directory}
547  cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release {source_directory}
548  nmake
549
550This will build either a 32-bit or a 64-bit version of libjpeg-turbo, depending
551on which version of cl.exe is in the PATH.
552
553The following files will be generated under {build_directory}:
554
555  jpeg-static.lib
556      Static link library for the libjpeg API
557  sharedlib/jpeg{version}.dll
558      DLL for the libjpeg API
559  sharedlib/jpeg.lib
560      Import library for the libjpeg API
561  turbojpeg-static.lib
562      Static link library for the TurboJPEG API
563  turbojpeg.dll
564      DLL for the TurboJPEG API
565  turbojpeg.lib
566      Import library for the TurboJPEG API
567
568{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
569v8 emulation is enabled.
570
571
572Visual C++ (IDE)
573----------------
574
575Choose the appropriate CMake generator option for your version of Visual Studio
576(run "cmake" with no arguments for a list of available generators.)  For
577instance:
578
579  cd {build_directory}
580  cmake -G "Visual Studio 10" {source_directory}
581
582NOTE:  Add "Win64" to the generator name (for example, "Visual Studio 10
583Win64") to build a 64-bit version of libjpeg-turbo.  Recent versions of CMake
584no longer document that.  A separate build directory must be used for 32-bit
585and 64-bit builds.
586
587You can then open ALL_BUILD.vcproj in Visual Studio and build one of the
588configurations in that project ("Debug", "Release", etc.) to generate a full
589build of libjpeg-turbo.
590
591This will generate the following files under {build_directory}:
592
593  {configuration}/jpeg-static.lib
594      Static link library for the libjpeg API
595  sharedlib/{configuration}/jpeg{version}.dll
596      DLL for the libjpeg API
597  sharedlib/{configuration}/jpeg.lib
598      Import library for the libjpeg API
599  {configuration}/turbojpeg-static.lib
600      Static link library for the TurboJPEG API
601  {configuration}/turbojpeg.dll
602      DLL for the TurboJPEG API
603  {configuration}/turbojpeg.lib
604      Import library for the TurboJPEG API
605
606{configuration} is Debug, Release, RelWithDebInfo, or MinSizeRel, depending on
607the configuration you built in the IDE, and {version} is 62, 7, or 8,
608depending on whether libjpeg v6b (default), v7, or v8 emulation is enabled.
609
610
611MinGW
612-----
613
614NOTE: This assumes that you are building on a Windows machine.  If you are
615cross-compiling on a Linux/Unix machine, then see "Build Recipes" below.
616
617  cd {build_directory}
618  cmake -G "MinGW Makefiles" {source_directory}
619  mingw32-make
620
621This will generate the following files under {build_directory}
622
623  libjpeg.a
624      Static link library for the libjpeg API
625  sharedlib/libjpeg-{version}.dll
626      DLL for the libjpeg API
627  sharedlib/libjpeg.dll.a
628      Import library for the libjpeg API
629  libturbojpeg.a
630      Static link library for the TurboJPEG API
631  libturbojpeg.dll
632      DLL for the TurboJPEG API
633  libturbojpeg.dll.a
634      Import library for the TurboJPEG API
635
636{version} is 62, 7, or 8, depending on whether libjpeg v6b (default), v7, or
637v8 emulation is enabled.
638
639
640Debug Build
641-----------
642
643Add "-DCMAKE_BUILD_TYPE=Debug" to the cmake command line.  Or, if building with
644NMake, remove "-DCMAKE_BUILD_TYPE=Release" (Debug builds are the default with
645NMake.)
646
647
648libjpeg v7 or v8 API/ABI Emulation
649-----------------------------------
650
651Add "-DWITH_JPEG7=1" to the cmake command line to build a version of
652libjpeg-turbo that is API/ABI-compatible with libjpeg v7.  Add "-DWITH_JPEG8=1"
653to the cmake command to build a version of libjpeg-turbo that is
654API/ABI-compatible with libjpeg v8.  See README-turbo.txt for more information
655on libjpeg v7 and v8 emulation.
656
657
658In-Memory Source/Destination Managers
659-------------------------------------
660
661When using libjpeg v6b or v7 API/ABI emulation, add -DWITH_MEM_SRCDST=0 to the
662CMake command line to build a version of libjpeg-turbo that lacks the
663jpeg_mem_src() and jpeg_mem_dest() functions.  These functions were not part of
664the original libjpeg v6b and v7 APIs, so removing them ensures strict
665conformance with those APIs.  See README-turbo.txt for more information.
666
667
668Arithmetic Coding Support
669-------------------------
670
671Since the patent on arithmetic coding has expired, this functionality has been
672included in this release of libjpeg-turbo.  libjpeg-turbo's implementation is
673based on the implementation in libjpeg v8, but it works when emulating libjpeg
674v7 or v6b as well.  The default is to enable both arithmetic encoding and
675decoding, but those who have philosophical objections to arithmetic coding can
676add "-DWITH_ARITH_ENC=0" or "-DWITH_ARITH_DEC=0" to the cmake command line to
677disable encoding or decoding (respectively.)
678
679
680TurboJPEG Java Wrapper
681----------------------
682Add "-DWITH_JAVA=1" to the cmake command line to incorporate an optional Java
683Native Interface wrapper into the TurboJPEG shared library and build the Java
684front-end classes to support it.  This allows the TurboJPEG shared library to
685be used directly from Java applications.  See java/README for more details.
686
687If you are using CMake 2.8, you can set the Java_JAVAC_EXECUTABLE,
688Java_JAVA_EXECUTABLE, and Java_JAR_EXECUTABLE CMake variables to specify
689alternate commands or locations for javac, jar, and java (respectively.)  If
690you are using CMake 2.6, set JAVA_COMPILE, JAVA_RUNTIME, and JAVA_ARCHIVE
691instead.  You can also set the JAVACFLAGS CMake variable to specify arguments
692that should be passed to the Java compiler when building the front-end classes.
693
694
695========================
696Installing libjpeg-turbo
697========================
698
699You can use the build system to install libjpeg-turbo into a directory of your
700choosing (as opposed to creating an installer.)  To do this, add:
701
702  -DCMAKE_INSTALL_PREFIX={install_directory}
703
704to the cmake command line.
705
706For example,
707
708  cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release \
709    -DCMAKE_INSTALL_PREFIX=c:\libjpeg-turbo {source_directory}
710  nmake install
711
712will install the header files in c:\libjpeg-turbo\include, the library files
713in c:\libjpeg-turbo\lib, the DLL's in c:\libjpeg-turbo\bin, and the
714documentation in c:\libjpeg-turbo\doc.
715
716
717=============
718Build Recipes
719=============
720
721
72264-bit MinGW Build on Cygwin
723----------------------------
724
725  cd {build_directory}
726  CC=/usr/bin/x86_64-w64-mingw32-gcc \
727    cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
728    -DCMAKE_RC_COMPILER=/usr/bin/x86_64-w64-mingw32-windres.exe \
729    {source_directory}
730  make
731
732This produces a 64-bit build of libjpeg-turbo that does not depend on
733cygwin1.dll or other Cygwin DLL's.  The mingw64-x86_64-gcc-core and
734mingw64-x86_64-gcc-g++ packages (and their dependencies) must be installed.
735
736
73732-bit MinGW Build on Cygwin
738----------------------------
739
740  cd {build_directory}
741  CC=/usr/bin/i686-w64-mingw32-gcc \
742    cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
743    -DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres.exe \
744    {source_directory}
745  make
746
747This produces a 32-bit build of libjpeg-turbo that does not depend on
748cygwin1.dll or other Cygwin DLL's.  The mingw64-i686-gcc-core and
749mingw64-i686-gcc-g++ packages (and their dependencies) must be installed.
750
751
752MinGW Build on Linux
753--------------------
754
755  cd {build_directory}
756  CC={mingw_binary_path}/i386-mingw32-gcc \
757    cmake -G "Unix Makefiles" -DCMAKE_SYSTEM_NAME=Windows \
758    -DCMAKE_AR={mingw_binary_path}/i386-mingw32-ar \
759    -DCMAKE_RANLIB={mingw_binary_path}/i386-mingw32-ranlib \
760    {source_directory}
761  make
762
763
764*******************************************************************************
765**     Creating Release Packages
766*******************************************************************************
767
768The following commands can be used to create various types of release packages:
769
770
771Unix/Linux
772----------
773
774make rpm
775
776  Create Red Hat-style binary RPM package.  Requires RPM v4 or later.
777
778make srpm
779
780  This runs 'make dist' to create a pristine source tarball, then creates a
781  Red Hat-style source RPM package from the tarball.  Requires RPM v4 or later.
782
783make deb
784
785  Create Debian-style binary package.  Requires dpkg.
786
787make dmg
788
789  Create Macintosh package/disk image.  This requires pkgbuild and
790  productbuild, which are installed by default on OS X 10.7 and later and which
791  can be obtained by installing Xcode 3.2.6 (with the "Unix Development"
792  option) on OS X 10.6.  Packages built in this manner can be installed on OS X
793  10.5 and later, but they must be built on OS X 10.6 or later.
794
795make udmg [BUILDDIR32={32-bit build directory}]
796
797  On 64-bit OS X systems, this creates a Macintosh package and disk image that
798  contains universal i386/x86-64 binaries.  You should first configure a 32-bit
799  out-of-tree build of libjpeg-turbo, then configure a 64-bit out-of-tree
800  build, then run 'make udmg' from the 64-bit build directory.  The build
801  system will look for the 32-bit build under {source_directory}/osxx86 by
802  default, but you can override this by setting the BUILDDIR32 variable on the
803  make command line as shown above.
804
805make iosdmg [BUILDDIR32={32-bit build directory}] \
806  [BUILDDIRARMV6={ARMv6 build directory}] \
807  [BUILDDIRARMV7={ARMv7 build directory}] \
808  [BUILDDIRARMV7S={ARMv7s build directory}] \
809  [BUILDDIRARMV8={ARMv8 build directory}]
810
811  On OS X systems, this creates a Macintosh package and disk image in which the
812  libjpeg-turbo static libraries contain ARM architectures necessary to build
813  iOS applications.  If building on an x86-64 system, the binaries will also
814  contain the i386 architecture, as with 'make udmg' above.  You should first
815  configure ARMv6, ARMv7, ARMv7s, and/or ARMv8 out-of-tree builds of
816  libjpeg-turbo (see "Building libjpeg-turbo for iOS" above.)  If you are
817  building an x86-64 version of libjpeg-turbo, you should configure a 32-bit
818  out-of-tree build as well.  Next, build libjpeg-turbo as you would normally,
819  using an out-of-tree build.  When it is built, run 'make iosdmg' from the
820  build directory.  The build system will look for the ARMv6 build under
821  {source_directory}/iosarmv6 by default, the ARMv7 build under
822  {source_directory}/iosarmv7 by default, the ARMv7s build under
823  {source_directory}/iosarmv7s by default, the ARMv8 build under
824  {source_directory}/iosarmv8 by default, and (if applicable) the 32-bit build
825  under {source_directory}/osxx86 by default, but you can override this by
826  setting the BUILDDIR32, BUILDDIRARMV6, BUILDDIRARMV7, BUILDDIRARMV7S, and/or
827  BUILDDIRARMV8 variables on the make command line as shown above.
828
829  NOTE: If including an ARMv8 build in the package, then you may need to use
830  Xcode's version of lipo instead of the operating system's.  To do this, pass
831  an argument of LIPO="xcrun lipo" on the make command line.
832
833make cygwinpkg
834
835  Build a Cygwin binary package.
836
837
838Windows
839-------
840
841If using NMake:
842
843  cd {build_directory}
844  nmake installer
845
846If using MinGW:
847
848  cd {build_directory}
849  make installer
850
851If using the Visual Studio IDE, build the "installer" project.
852
853The installer package (libjpeg-turbo[-gcc][64].exe) will be located under
854{build_directory}.  If building using the Visual Studio IDE, then the installer
855package will be located in a subdirectory with the same name as the
856configuration you built (such as {build_directory}\Debug\ or
857{build_directory}\Release\).
858
859Building a Windows installer requires the Nullsoft Install System
860(http://nsis.sourceforge.net/.)  makensis.exe should be in your PATH.
861
862
863*******************************************************************************
864**     Regression testing
865*******************************************************************************
866
867The most common way to test libjpeg-turbo is by invoking 'make test' on
868Unix/Linux platforms or 'ctest' on Windows platforms, once the build has
869completed.  This runs a series of tests to ensure that mathematical
870compatibility has been maintained between libjpeg-turbo and libjpeg v6b.  This
871also invokes the TurboJPEG unit tests, which ensure that the colorspace
872extensions, YUV encoding, decompression scaling, and other features of the
873TurboJPEG C and Java APIs are working properly (and, by extension, that the
874equivalent features of the underlying libjpeg API are also working.)
875
876Invoking 'make testclean' or 'nmake testclean' (if using NMake) or building
877the 'testclean' target (if using the Visual Studio IDE) will clean up the
878output images generated by 'make test'.
879
880On Unix/Linux platforms, more extensive tests of the TurboJPEG C and Java
881wrappers can be run by invoking 'make tjtest'.  These extended TurboJPEG tests
882essentially iterate through all of the available features of the TurboJPEG APIs
883that are not covered by the TurboJPEG unit tests (this includes the lossless
884transform options) and compare the images generated by each feature to images
885generated using the equivalent feature in the libjpeg API.  The extended
886TurboJPEG tests are meant to test for regressions in the TurboJPEG wrappers,
887not in the underlying libjpeg API library.
888