image_pack 0.2.2 → 0.2.3

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