image_optim_pack 0.5.0-x86-openbsd

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +79 -0
  4. data/.travis.yml +35 -0
  5. data/CHANGELOG.markdown +210 -0
  6. data/Gemfile +7 -0
  7. data/LICENSE.txt +27 -0
  8. data/Makefile +393 -0
  9. data/README.markdown +93 -0
  10. data/Vagrantfile +60 -0
  11. data/acknowledgements/7z.txt +56 -0
  12. data/acknowledgements/advancecomp.txt +674 -0
  13. data/acknowledgements/bmp2png.txt +8 -0
  14. data/acknowledgements/cexcept.txt +8 -0
  15. data/acknowledgements/gifread.txt +14 -0
  16. data/acknowledgements/gifsicle.txt +343 -0
  17. data/acknowledgements/iqa.txt +30 -0
  18. data/acknowledgements/jhead.txt +12 -0
  19. data/acknowledgements/jpeg-archive.txt +20 -0
  20. data/acknowledgements/jpegoptim.txt +339 -0
  21. data/acknowledgements/libjpeg-turbo.txt +27 -0
  22. data/acknowledgements/libjpeg-x86-simd.txt +17 -0
  23. data/acknowledgements/libjpeg.txt +64 -0
  24. data/acknowledgements/libpng.txt +90 -0
  25. data/acknowledgements/mozjpeg.txt +7 -0
  26. data/acknowledgements/optipng-authors.txt +26 -0
  27. data/acknowledgements/optipng.txt +21 -0
  28. data/acknowledgements/pngcrush.txt +35 -0
  29. data/acknowledgements/pngquant.txt +56 -0
  30. data/acknowledgements/smallfry.txt +13 -0
  31. data/acknowledgements/zlib.txt +34 -0
  32. data/acknowledgements/zopfli-contributors.txt +6 -0
  33. data/acknowledgements/zopfli.txt +201 -0
  34. data/boxes/.gitignore +3 -0
  35. data/boxes/.rubocop.yml +13 -0
  36. data/boxes/Gemfile +11 -0
  37. data/boxes/Rakefile +144 -0
  38. data/boxes/definitions/freebsd-amd64/definition.rb +38 -0
  39. data/boxes/definitions/freebsd-amd64/install.sh +66 -0
  40. data/boxes/definitions/freebsd-i386/definition.rb +38 -0
  41. data/boxes/definitions/freebsd-i386/install.sh +66 -0
  42. data/boxes/definitions/freebsd-postinstall.sh +38 -0
  43. data/boxes/definitions/openbsd-amd64/definition.rb +71 -0
  44. data/boxes/definitions/openbsd-i386/definition.rb +71 -0
  45. data/boxes/definitions/openbsd-postinstall.sh +29 -0
  46. data/image_optim_pack-darwin-x86.gemspec +3 -0
  47. data/image_optim_pack-darwin-x86_64.gemspec +3 -0
  48. data/image_optim_pack-freebsd-amd64.gemspec +3 -0
  49. data/image_optim_pack-freebsd-x86.gemspec +3 -0
  50. data/image_optim_pack-linux-x86.gemspec +3 -0
  51. data/image_optim_pack-linux-x86_64.gemspec +3 -0
  52. data/image_optim_pack-openbsd-x86.gemspec +3 -0
  53. data/image_optim_pack-openbsd-x86_64.gemspec +3 -0
  54. data/image_optim_pack.gemspec +41 -0
  55. data/lib/image_optim/pack.rb +117 -0
  56. data/lib/image_optim_pack.rb +1 -0
  57. data/script/livecheck +116 -0
  58. data/script/run +71 -0
  59. data/script/update_versions +22 -0
  60. data/spec/image_optim/pack_spec.rb +114 -0
  61. data/spec/image_optim_spec.rb +39 -0
  62. data/spec/spec_helper.rb +8 -0
  63. data/vendor/openbsd-i386/advpng +0 -0
  64. data/vendor/openbsd-i386/gifsicle +0 -0
  65. data/vendor/openbsd-i386/jhead +0 -0
  66. data/vendor/openbsd-i386/jpeg-recompress +0 -0
  67. data/vendor/openbsd-i386/jpegoptim +0 -0
  68. data/vendor/openbsd-i386/jpegtran +0 -0
  69. data/vendor/openbsd-i386/libjpeg.so +0 -0
  70. data/vendor/openbsd-i386/libpng.so +0 -0
  71. data/vendor/openbsd-i386/libz.so +0 -0
  72. data/vendor/openbsd-i386/optipng +0 -0
  73. data/vendor/openbsd-i386/pngcrush +0 -0
  74. data/vendor/openbsd-i386/pngquant +0 -0
  75. metadata +182 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a41a16167b80cf9ef3be4d80351b7700d390d765
4
+ data.tar.gz: dea14064b1a90dd26696bb3640a9a703b58b3c04
5
+ SHA512:
6
+ metadata.gz: 62e54ac7630941d61d1e39922a2223ad6efd5a1cc44a77f9ffd82811627379924349f46d56c717fd3ea58fd0d4c578a6aa1ac5637deabc5b7d70140daa6cb1ea
7
+ data.tar.gz: 07620d4cb2e2743b45d130500c5faa0aa7194933ec9da9721947a55f27a6e35733d3b5f616dd8a8a5bced516cc7822c82e2811b7093f57af20c6d083e05b4930
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /build/
2
+ /download/
3
+ /.vagrant/
4
+
5
+ Gemfile.lock
6
+ /*.gem
7
+ /.bundle
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,79 @@
1
+ AllCops:
2
+ Exclude:
3
+ - '*.gemspec'
4
+ - 'build/**/*'
5
+ - 'download/**/*'
6
+ - Vagrantfile
7
+
8
+ Bundler/OrderedGems:
9
+ Enabled: false
10
+
11
+ Metrics/BlockLength:
12
+ Exclude:
13
+ - spec/**/*_spec.rb
14
+
15
+ Metrics/MethodLength:
16
+ Max: 15
17
+
18
+ Security/YAMLLoad:
19
+ Exclude:
20
+ - script/livecheck
21
+
22
+ Style/AccessModifierIndentation:
23
+ EnforcedStyle: outdent
24
+
25
+ Style/Alias:
26
+ EnforcedStyle: prefer_alias_method
27
+
28
+ Style/DotPosition:
29
+ EnforcedStyle: trailing
30
+
31
+ Style/DoubleNegation:
32
+ Enabled: false
33
+
34
+ Style/EmptyCaseCondition:
35
+ Enabled: false
36
+
37
+ Style/Encoding:
38
+ EnforcedStyle: when_needed
39
+
40
+ Style/HashSyntax:
41
+ EnforcedStyle: hash_rockets
42
+
43
+ Style/IfUnlessModifier:
44
+ MaxLineLength: 40
45
+
46
+ Style/IndentHash:
47
+ EnforcedStyle: consistent
48
+
49
+ Style/MultilineBlockChain:
50
+ Enabled: false
51
+
52
+ Style/PercentLiteralDelimiters:
53
+ PreferredDelimiters:
54
+ '%w': '[]'
55
+ '%W': '[]'
56
+
57
+ Style/Semicolon:
58
+ AllowAsExpressionSeparator: true
59
+
60
+ Style/SignalException:
61
+ EnforcedStyle: semantic
62
+
63
+ Style/SpaceBeforeBlockBraces:
64
+ EnforcedStyle: no_space
65
+
66
+ Style/SpaceInsideHashLiteralBraces:
67
+ EnforcedStyle: no_space
68
+
69
+ Style/SpecialGlobalVars:
70
+ Enabled: false
71
+
72
+ Style/SymbolArray:
73
+ Enabled: false
74
+
75
+ Style/TrailingCommaInArguments:
76
+ EnforcedStyleForMultiline: no_comma
77
+
78
+ Style/TrailingCommaInLiteral:
79
+ EnforcedStyleForMultiline: comma
data/.travis.yml ADDED
@@ -0,0 +1,35 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - '1.8.7-p371'
5
+ - '1.9.3-p551'
6
+ - '2.0.0-p648'
7
+ - '2.1.10'
8
+ - '2.2.7'
9
+ - '2.3.4'
10
+ - '2.4.1'
11
+ - 'jruby-1.7.26'
12
+ - 'jruby-9.0.5.0'
13
+ - 'jruby-9.1.5.0'
14
+ script:
15
+ - make test
16
+ - bundle exec image_optim --info
17
+ - bundle exec rspec
18
+ before_install:
19
+ if [ $TRAVIS_OS_NAME == osx ]; then brew update && brew install imagemagick; fi
20
+ matrix:
21
+ include:
22
+ - dist: trusty
23
+ rvm: default
24
+ - os: osx
25
+ rvm: default
26
+ osx_image: xcode7.3
27
+ - os: osx
28
+ rvm: default
29
+ osx_image: xcode8.3
30
+ - env: RUBOCOP=✓
31
+ rvm: '2.4.1'
32
+ script: bundle exec rubocop
33
+ - env: CHECK_RUBIES=✓
34
+ rvm: '2.4.1'
35
+ script: bundle exec travis_check_rubies
@@ -0,0 +1,210 @@
1
+ # ChangeLog
2
+
3
+ ## unreleased
4
+
5
+ ## v0.5.0 (2017-05-06)
6
+
7
+ * Add gemspec for each platform to also release per platform gems [@toy](https://github.com/toy)
8
+
9
+ ## v0.4.0 (2017-04-26)
10
+
11
+ * pngquant 2.9.1 [@toy](https://github.com/toy)
12
+ * Rebuild all binaries [@toy](https://github.com/toy)
13
+ * Update freebsd box definition to 10.3 [@toy](https://github.com/toy)
14
+ * Switching to ubuntu for linux as centos has outdated gcc, remove centos boxes definitions [@toy](https://github.com/toy)
15
+ * Fix pngcrush makefile variable overrides [@toy](https://github.com/toy)
16
+ * Allow custom structure of projects in Makefile which doesn't allow to put resulting binary in the root folder [@toy](https://github.com/toy)
17
+
18
+ ## v0.3.1.20170318 (2017-03-18)
19
+
20
+ * libpng 1.6.29 [@toy](https://github.com/toy)
21
+
22
+ ## v0.3.1.20170311 (2017-03-11)
23
+
24
+ * pngquant 2.9.0 [@toy](https://github.com/toy)
25
+
26
+ ## v0.3.1.20170121 (2017-01-21)
27
+
28
+ * libpng 1.6.28, libz 1.2.11 and pngcrush 1.8.11 [@toy](https://github.com/toy)
29
+
30
+ ## v0.3.1 (2016-12-30)
31
+
32
+ * libpng 1.6.27 and pngquant 2.8.2 [@toy](https://github.com/toy)
33
+ * Makefile cleanup [@toy](https://github.com/toy)
34
+
35
+ ## v0.3.0.20161206 (2016-12-06)
36
+
37
+ * pngquant 2.8.1 (resort to cloning due to submodule not in archive) [@toy](https://github.com/toy)
38
+ * advpng 1.23 [@toy](https://github.com/toy)
39
+ * advpng 1.22 (windows related change) [@toy](https://github.com/toy)
40
+
41
+ ## v0.3.0.20161108 (2016-11-08)
42
+
43
+ * advpng 1.21 [@toy](https://github.com/toy)
44
+ * pngcrush 1.8.10 [@toy](https://github.com/toy)
45
+
46
+ ## v0.3.0.20161021 (2016-10-21)
47
+
48
+ * libpng 1.6.26 [@toy](https://github.com/toy)
49
+ * pngcrush 1.8.8 [@toy](https://github.com/toy)
50
+
51
+ ## v0.3.0.20160927 (2016-09-27)
52
+
53
+ * pngcrush 1.8.7 [@toy](https://github.com/toy)
54
+
55
+ ## v0.3.0.20160905 (2016-09-05)
56
+
57
+ * libpng 1.6.25 and pngcrush 1.8.6 [@toy](https://github.com/toy)
58
+ * jpegoptim 1.4.4 [@toy](https://github.com/toy)
59
+
60
+ ## v0.3.0.20160812 (2016-08-12)
61
+
62
+ * pngcrush 1.8.4 [@toy](https://github.com/toy)
63
+
64
+ ## v0.3.0.20160806 (2016-08-06)
65
+
66
+ * libpng 1.6.24 [@toy](https://github.com/toy)
67
+
68
+ ## v0.3.0 (2016-07-27)
69
+
70
+ * Add FreeBSD and OpenBSD binaries [toy/image_optim#89](https://github.com/toy/image_optim/issues/89) [toy/image_optim#90](https://github.com/toy/image_optim/issues/90) [@toy](https://github.com/toy)
71
+ * Flatten vendor paths from os/arch to os-arch [@toy](https://github.com/toy)
72
+ * Add script for build build boxes using veewee [@toy](https://github.com/toy)
73
+ * pngcrush 1.8.2 [@toy](https://github.com/toy)
74
+
75
+ ## v0.2.3 (2016-07-09)
76
+
77
+ * Change dependency on fspath to allow versions 2.1...4 [@toy](https://github.com/toy)
78
+
79
+ ## v0.2.2 (2016-07-09)
80
+
81
+ * advancecomp 1.20 [@toy](https://github.com/toy)
82
+ * Rescue `Errno::ENOENT` on load when uname is not available [@toy](https://github.com/toy)
83
+
84
+ ## v0.2.1.20160610 (2016-06-10)
85
+
86
+ * libpng 1.6.23 and pngquant 2.7.1 [@toy](https://github.com/toy)
87
+
88
+ ## v0.2.1.20160510 (2016-05-10)
89
+
90
+ * pngquant 2.7.0 [@toy](https://github.com/toy)
91
+
92
+ ## v0.2.1.20160413 (2016-04-13)
93
+
94
+ * pngcrush 1.8.1 [@toy](https://github.com/toy)
95
+
96
+ ## v0.2.1.20160406 (2016-04-06)
97
+
98
+ * optipng 0.7.6 [@toy](https://github.com/toy)
99
+
100
+ ## v0.2.1.20160221 (2016-02-21)
101
+
102
+ * pngquant 2.6.0 [@toy](https://github.com/toy)
103
+
104
+ ## v0.2.1.20160119 (2016-01-19)
105
+
106
+ * libjpeg 9b [@toy](https://github.com/toy)
107
+
108
+ ## v0.2.1.20160117 (2016-01-17)
109
+
110
+ * pngcrush 1.8.0 [@toy](https://github.com/toy)
111
+ * libpng 1.6.21 [@toy](https://github.com/toy)
112
+
113
+ ## v0.2.1.20160103 (2016-01-03)
114
+
115
+ * libpng 1.6.20 and pngcrush 1.7.92 [@toy](https://github.com/toy)
116
+
117
+ ## v0.2.1.20151113 (2015-11-13)
118
+
119
+ * libpng 1.6.19 and pngcrush 1.7.88 [@toy](https://github.com/toy)
120
+
121
+ ## v0.2.1.20151012 (2015-10-12)
122
+
123
+ * pngcrush 1.7.87 [@toy](https://github.com/toy)
124
+
125
+ ## v0.2.1.20151002 (2015-10-02)
126
+
127
+ * pngquant 2.5.2 [@toy](https://github.com/toy)
128
+
129
+ ## v0.2.1.20150808 (2015-08-08)
130
+
131
+ * pngquant 2.5.1 [@toy](https://github.com/toy)
132
+
133
+ ## v0.2.1.20150802 (2015-08-02)
134
+
135
+ * libpng 1.6.18 and pngcrush 1.7.86 [@toy](https://github.com/toy)
136
+
137
+ ## v0.2.1.20150702 (2015-07-02)
138
+
139
+ * gifsicle 1.88 and pngquant 2.5.0 [@toy](https://github.com/toy)
140
+
141
+ ## v0.2.1.20150525 (2015-05-25)
142
+
143
+ * jpegoptim 1.4.2 and libmozjpeg 3.1 [@toy](https://github.com/toy)
144
+
145
+ ## v0.2.1.20150422 (2015-04-22)
146
+
147
+ * jpegarchive 2.1.1 [@toy](https://github.com/toy)
148
+ * pngquant 2.4.1 [@toy](https://github.com/toy)
149
+
150
+ ## v0.2.1.20150411 (2015-04-11)
151
+
152
+ * jpegarchive 2.1.0 using libmozjpeg 3.0 [@toy](https://github.com/toy)
153
+
154
+ ## v0.2.1.20150407 (2015-04-07)
155
+
156
+ * pngquant 2.3.6 [@toy](https://github.com/toy)
157
+
158
+ ## v0.2.1.20150327 (2015-03-27)
159
+
160
+ * libpng 1.6.17 [@toy](https://github.com/toy)
161
+
162
+ ## v0.2.1.20150310 (2015-03-10)
163
+
164
+ * pngcrush 1.7.85 and pngquant 2.3.5 [@toy](https://github.com/toy)
165
+
166
+ ## v0.2.1.20150305 (2015-03-05)
167
+
168
+ * pngcrush 1.7.84 [@toy](https://github.com/toy)
169
+
170
+ ## v0.2.1.20150203 (2015-02-03)
171
+
172
+ * jhead 3.00 [@toy](https://github.com/toy)
173
+
174
+ ## v0.2.1.20150201 (2015-02-01)
175
+
176
+ * pngquant 2.3.4 [@toy](https://github.com/toy)
177
+
178
+ ## v0.2.1.20150129 (2015-01-29)
179
+
180
+ * pngcrush 1.7.83 [@toy](https://github.com/toy)
181
+
182
+ ## v0.2.1.20150107 (2015-01-07)
183
+
184
+ * pngquant 2.3.3 (2.3.2 skipped due to [pornel/pngquant#133](https://github.com/pornel/pngquant/issues/133)) [@toy](https://github.com/toy)
185
+
186
+ ## v0.2.1 (2014-12-23)
187
+
188
+ * jpegoptim 1.4.1, libpng 1.6.16, pngcrush 1.7.82 [@toy](https://github.com/toy)
189
+
190
+ ## v0.2.0.20141210 (2014-12-10)
191
+
192
+ * gifsicle 1.87 [@toy](https://github.com/toy)
193
+
194
+ ## v0.2.0.20141122 (2014-11-22)
195
+
196
+ * libpng 1.6.15 [@toy](https://github.com/toy)
197
+ * pngcrush 1.7.81 [@toy](https://github.com/toy)
198
+ * pngcrush 1.7.80 [@toy](https://github.com/toy)
199
+
200
+ ## v0.2.0 (2014-11-08)
201
+
202
+ * Add `jpeg-recompress` from [jpeg-archive](https://github.com/danielgtaylor/jpeg-archive) [@toy](https://github.com/toy)
203
+
204
+ ## v0.1.0.20141104 (2014-11-04)
205
+
206
+ * pngcrush 1.7.79 [@toy](https://github.com/toy)
207
+
208
+ ## v0.1.0 (2014-11-01)
209
+
210
+ * Initial release [@toy](https://github.com/toy)
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec :name => 'image_optim_pack'
4
+
5
+ if RUBY_VERSION >= '2.0'
6
+ gem 'travis_check_rubies', '~> 0.2'
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2014-2017 Ivan Kuchin
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ ======================================================================
23
+
24
+ All binaries and libraries in vendor directory are written by
25
+ different authors. References can be found in README.markdown.
26
+ COPYRIGHTS, DISCLAIMERS, LICENSES and NOTES can be found in
27
+ acknowledgements directory.
data/Makefile ADDED
@@ -0,0 +1,393 @@
1
+ all :
2
+
3
+ # ====== VERSIONS ======
4
+
5
+ ADVANCECOMP_VER := 1.23
6
+ GIFSICLE_VER := 1.88
7
+ JHEAD_VER := 3.00
8
+ JPEGARCHIVE_VER := 2.1.1
9
+ JPEGOPTIM_VER := 1.4.4
10
+ LIBJPEG_VER := 9b
11
+ LIBMOZJPEG_VER := 3.1
12
+ LIBPNG_VER := 1.6.29
13
+ LIBZ_VER := 1.2.11
14
+ OPTIPNG_VER := 0.7.6
15
+ PNGCRUSH_VER := 1.8.11
16
+ PNGQUANT_VER := 2.9.1
17
+
18
+ # ====== CONSTANTS ======
19
+
20
+ OS := $(shell uname -s | tr A-Z a-z)
21
+ ARCH := $(shell uname -m)
22
+
23
+ IS_DARWIN := $(findstring darwin,$(OS))
24
+ IS_LINUX := $(findstring linux,$(OS))
25
+ IS_BSD := $(findstring bsd,$(OS))
26
+ IS_FREEBSD := $(findstring freebsd,$(OS))
27
+ IS_OPENBSD := $(findstring openbsd,$(OS))
28
+ DLEXT := $(if $(IS_DARWIN),.dylib,.so)
29
+ HOST := $(ARCH)-$(if $(IS_DARWIN),apple,pc)-$(OS)
30
+
31
+ DL_DIR := $(CURDIR)/download
32
+ BUILD_ROOT_DIR := $(CURDIR)/build
33
+ BUILD_DIR := $(BUILD_ROOT_DIR)/$(OS)-$(ARCH)
34
+ OUTPUT_ROOT_DIR := $(CURDIR)/vendor
35
+ OUTPUT_DIR := $(OUTPUT_ROOT_DIR)/$(OS)-$(ARCH)
36
+ $(shell mkdir -p $(DL_DIR) $(BUILD_DIR) $(OUTPUT_DIR))
37
+
38
+ ANSI_RED=\033[31m
39
+ ANSI_GREEN=\033[32m
40
+ ANSI_MAGENTA=\033[35m
41
+ ANSI_RESET=\033[0m
42
+
43
+ # ====== HELPERS ======
44
+
45
+ downcase = $(shell echo $1 | tr A-Z a-z)
46
+
47
+ ln_s := ln -sf
48
+ tar := $(shell if command -v gtar >/dev/null 2>&1; then echo gtar; else echo tar; fi)
49
+
50
+ # ====== ARCHIVES ======
51
+
52
+ ARCHIVES :=
53
+
54
+ # $1 - name of archive
55
+ define archive
56
+ ARCHIVES += $1
57
+ $1_DIR := $(BUILD_DIR)/$(call downcase,$1)
58
+ $1_TGZ := $(DL_DIR)/$(call downcase,$1)-$($1_VER).tar.gz
59
+ $1_EXTRACTED := $$($1_DIR)/__$$(notdir $$($1_TGZ))__
60
+ $$($1_EXTRACTED) : $$($1_TGZ)
61
+ rm -rf $$(@D)
62
+ mkdir $$(@D)
63
+ $(tar) -C $$(@D) --strip-components=1 -xzf $$<
64
+ touch $$(@D)/__$$(notdir $$<)__
65
+ endef
66
+
67
+ # $1 - name of archive
68
+ # $2 - url of archive with [VER] for replace with version
69
+ define archive-dl
70
+ $(call archive,$1)
71
+ # download archive from url
72
+ $$($1_TGZ) :
73
+ while ! mkdir $$@.lock 2> /dev/null; do sleep 1; done
74
+ wget -q -O $$@.tmp $(subst [VER],$($1_VER),$(strip $2))
75
+ mv $$@.tmp $$@
76
+ rm -r $$@.lock
77
+ endef
78
+
79
+ $(eval $(call archive-dl,ADVANCECOMP, https://github.com/amadvance/advancecomp/releases/download/v[VER]/advancecomp-[VER].tar.gz))
80
+ $(eval $(call archive-dl,GIFSICLE, http://www.lcdf.org/gifsicle/gifsicle-[VER].tar.gz))
81
+ $(eval $(call archive-dl,JHEAD, http://www.sentex.net/~mwandel/jhead/jhead-[VER].tar.gz))
82
+ $(eval $(call archive-dl,JPEGARCHIVE, https://github.com/danielgtaylor/jpeg-archive/archive/[VER].tar.gz))
83
+ $(eval $(call archive-dl,JPEGOPTIM, http://www.kokkonen.net/tjko/src/jpegoptim-[VER].tar.gz))
84
+ $(eval $(call archive-dl,LIBJPEG, http://www.ijg.org/files/jpegsrc.v[VER].tar.gz))
85
+ $(eval $(call archive-dl,LIBMOZJPEG, https://github.com/mozilla/mozjpeg/archive/v[VER].tar.gz))
86
+ $(eval $(call archive-dl,LIBPNG, http://prdownloads.sourceforge.net/libpng/libpng-[VER].tar.gz?download))
87
+ $(eval $(call archive-dl,LIBZ, http://prdownloads.sourceforge.net/libpng/zlib-[VER].tar.gz?download))
88
+ $(eval $(call archive-dl,OPTIPNG, http://prdownloads.sourceforge.net/optipng/optipng-[VER].tar.gz?download))
89
+ $(eval $(call archive-dl,PNGCRUSH, http://prdownloads.sourceforge.net/pmt/pngcrush-[VER]-nolib.tar.gz?download))
90
+ $(eval $(call archive,PNGQUANT))
91
+
92
+ PNGQUANT_GIT := $(DL_DIR)/pngquant.git
93
+ $(PNGQUANT_GIT) :; git clone --recursive https://github.com/pornel/pngquant.git $@
94
+ $(PNGQUANT_TGZ) : $(PNGQUANT_GIT)
95
+ while ! mkdir $@.lock 2> /dev/null; do sleep 1; done
96
+ cd $(PNGQUANT_GIT) && git fetch && git checkout -q $(PNGQUANT_VER) && git submodule -q update
97
+ cd $(PNGQUANT_GIT) && $(tar) --exclude=.git -czf $(PNGQUANT_TGZ) .
98
+ rm -r $@.lock
99
+
100
+ download : $(foreach archive,$(ARCHIVES),$($(archive)_TGZ))
101
+ .PHONY : download
102
+
103
+ download-tidy-up :
104
+ rm -f $(filter-out $(foreach archive,$(ARCHIVES),$($(archive)_TGZ)) $(PNGQUANT_GIT),$(wildcard $(DL_DIR)/*.*))
105
+ .PHONY : download-tidy-up
106
+
107
+ # ====== PRODUCTS ======
108
+
109
+ PRODUCTS :=
110
+
111
+ # $1 - product name
112
+ # $2 - archive name ($1 if empty)
113
+ # $3 - path ($1 if empty)
114
+ define target-build
115
+ $1_PATH := $(or $3,$(call downcase,$1))
116
+ $1_BASENAME := $$(notdir $$($1_PATH))
117
+ $1_DIR := $($(or $2,$1)_DIR)
118
+ $1_TGZ := $($(or $2,$1)_TGZ)
119
+ $1_EXTRACTED := $($(or $2,$1)_EXTRACTED)
120
+ $1_TARGET := $$($1_DIR)/$$($1_PATH)
121
+ $$($1_TARGET) : DIR := $$($1_DIR)
122
+ $$($1_TARGET) : $$($1_EXTRACTED)
123
+ endef
124
+
125
+ # $1 - product name
126
+ # $2 - archive name ($1 if empty)
127
+ # $3 - basename ($1 if empty)
128
+ define target
129
+ $(call target-build,$1,$2,$3)
130
+ PRODUCTS += $1
131
+ $1_DESTINATION := $$(OUTPUT_DIR)/$$($1_BASENAME)
132
+ # copy product to output dir
133
+ $$($1_DESTINATION) : $$($1_TARGET)
134
+ temppath=`mktemp "$(BUILD_DIR)"/tmp.XXXXXXXXXX` && \
135
+ strip $$< -Sx -o "$$$$temppath" && \
136
+ chmod 755 "$$$$temppath" && \
137
+ mv "$$$$temppath" $$@
138
+ # short name target
139
+ $(call downcase,$1) : | $$($1_DESTINATION)
140
+ endef
141
+
142
+ $(eval $(call target,ADVPNG,ADVANCECOMP))
143
+ $(eval $(call target,GIFSICLE,,src/gifsicle))
144
+ $(eval $(call target,JHEAD))
145
+ $(eval $(call target,JPEG-RECOMPRESS,JPEGARCHIVE))
146
+ $(eval $(call target,JPEGOPTIM))
147
+ $(eval $(call target,JPEGTRAN,LIBJPEG,.libs/jpegtran))
148
+ $(eval $(call target,LIBJPEG,,libjpeg$(DLEXT)))
149
+ $(eval $(call target-build,LIBMOZJPEG,,libjpeg.a))
150
+ $(eval $(call target,LIBPNG,,libpng$(DLEXT)))
151
+ $(eval $(call target,LIBZ,,libz$(DLEXT)))
152
+ $(eval $(call target,OPTIPNG,,src/optipng/optipng))
153
+ $(eval $(call target,PNGCRUSH))
154
+ $(eval $(call target,PNGQUANT))
155
+
156
+ # ====== TARGETS ======
157
+
158
+ all : build
159
+ @$(MAKE) test
160
+ .PHONY : all
161
+
162
+ build : $(call downcase,$(PRODUCTS))
163
+ .PHONY : build
164
+
165
+ define check_bin
166
+ @test -f $(OUTPUT_DIR)/$1 || \
167
+ { printf "$(ANSI_RED)no $1 found$(ANSI_RESET)\n"; exit 1; }
168
+ @printf "$1: "; \
169
+ VERSION=$$($(OUTPUT_DIR)/$1 $2 | fgrep -o $3) || \
170
+ { printf "$(ANSI_RED)Expected $3, got $$($(OUTPUT_DIR)/$1 $2)$(ANSI_RESET)\n"; exit 1; }; \
171
+ ARCH=$$(file -b $(OUTPUT_DIR)/$1 | fgrep -o '$(ARCH_STRING)') || \
172
+ { printf "$(ANSI_RED)Expected $(ARCH_STRING), got $$(file -b $(OUTPUT_DIR)/$1)$(ANSI_RESET)\n"; exit 1; }; \
173
+ printf "$(ANSI_GREEN)$$VERSION$(ANSI_RESET) / $(ANSI_MAGENTA)$$ARCH$(ANSI_RESET)\n"
174
+ endef
175
+
176
+ ifdef IS_DARWIN
177
+ test : ARCH_STRING := $(ARCH)
178
+ else ifeq (i386,$(ARCH:i686=i386))
179
+ test : ARCH_STRING := 80386
180
+ else ifeq (amd64,$(ARCH:x86_64=amd64))
181
+ test : ARCH_STRING := x86-64
182
+ endif
183
+ test :
184
+ $(if $(ARCH_STRING),,@echo Detecting 'ARCH $(ARCH) for OS $(OS) undefined'; false)
185
+ $(call check_bin,advpng,--version 2>&1,$(ADVANCECOMP_VER))
186
+ $(call check_bin,gifsicle,--version,$(GIFSICLE_VER))
187
+ $(call check_bin,jhead,-V,$(JHEAD_VER))
188
+ $(call check_bin,jpeg-recompress,--version,$(JPEGARCHIVE_VER))
189
+ $(call check_bin,jpegoptim,--version,$(JPEGOPTIM_VER))
190
+ $(call check_bin,jpegtran,-v - 2>&1,$(LIBJPEG_VER))
191
+ $(call check_bin,optipng,--version,$(OPTIPNG_VER))
192
+ $(call check_bin,pngcrush,-version 2>&1,$(PNGCRUSH_VER))
193
+ $(call check_bin,pngquant,--help,$(PNGQUANT_VER))
194
+ .PHONY : test
195
+
196
+ livecheck :; @$(foreach archive,$(ARCHIVES),script/livecheck $(call downcase,$(archive)) $($(archive)_VER);)
197
+ .PHONY : livecheck
198
+
199
+ Makefile.updated :
200
+ cat Makefile | script/update_versions > Makefile.updated
201
+
202
+ update-versions : Makefile.updated
203
+ mv Makefile.updated Makefile
204
+ .PHONY : update-versions
205
+
206
+ # ====== CLEAN ======
207
+
208
+ clean :
209
+ rm -rf $(BUILD_DIR)
210
+ rm -rf $(OUTPUT_DIR)
211
+ .PHONY : clean
212
+
213
+ clean-all :
214
+ rm -rf $(BUILD_ROOT_DIR)
215
+ rm -rf $(OUTPUT_ROOT_DIR)
216
+ .PHONY : clean-all
217
+
218
+ clobber : clean-all
219
+ rm -rf $(DL_DIR)
220
+ .PHONY : clobber
221
+
222
+ # ====== BUILD HELPERS ======
223
+
224
+ # $1 - name of product
225
+ # $2 - list of dependency products
226
+ define depend-build
227
+ # depend this product on every specified product
228
+ $($1_EXTRACTED) : $$(filter-out $($1_EXTRACTED),$(foreach dep,$2,$$($(dep)_EXTRACTED)))
229
+ $($1_TARGET) : $(foreach dep,$2,$$($(dep)_TARGET))
230
+ # add dependent product dir to CPATH, LIBRARY_PATH and PKG_CONFIG_PATH
231
+ $($1_TARGET) : export CPATH := $(subst $(eval) ,:,$(foreach dep,$2,$$($(dep)_DIR)))
232
+ $($1_TARGET) : export LIBRARY_PATH := $$(CPATH)
233
+ $($1_TARGET) : export PKG_CONFIG_PATH := $$(CPATH)
234
+ endef
235
+
236
+ # $1 - name of product
237
+ # $2 - list of dependency products
238
+ define depend
239
+ $(call depend-build,$1,$2)
240
+ # depend output of this product on output of every specified product
241
+ $$($1_DESTINATION) : $(foreach dep,$2,$$($(dep)_DESTINATION))
242
+ endef
243
+
244
+ pkgconfig_pwd = perl -pi -e 's/(?<=dir=).*/$$ENV{PWD}/'
245
+
246
+ libtool_target_soname = perl -pi -e 's/(?<=soname_spec=)".*"/"$(@F)"/ ; s/(?<=library_names_spec=)".*"/"\\\$$libname\\\$$shared_ext"/' -- libtool
247
+
248
+ ifdef IS_DARWIN
249
+ chrpath_origin =
250
+ else ifdef IS_OPENBSD
251
+ chrpath_origin = perl -pi -e 's/XORIGIN/\$$ORIGIN/' -- $1
252
+ else
253
+ chrpath_origin = chrpath -r '$$ORIGIN' $1
254
+ endif
255
+
256
+ ifdef IS_LINUX
257
+ XORIGIN := -Wl,-rpath,XORIGIN
258
+ else ifdef IS_BSD
259
+ XORIGIN := -Wl,-rpath,XORIGIN -Wl,-z,origin
260
+ else
261
+ XORIGIN :=
262
+ endif
263
+
264
+ # ====== ENV ======
265
+
266
+ export CC := gcc
267
+ export CXX := g++
268
+
269
+ GCC_FLAGS := -O3
270
+ export CFLAGS = $(GCC_FLAGS)
271
+ export CXXFLAGS = $(GCC_FLAGS)
272
+ export CPPFLAGS = $(GCC_FLAGS)
273
+ export LDFLAGS = $(GCC_FLAGS)
274
+
275
+ ifdef IS_DARWIN
276
+ export MACOSX_DEPLOYMENT_TARGET := 10.6
277
+ GCC_FLAGS += -arch $(ARCH)
278
+ endif
279
+
280
+ ifdef IS_BSD
281
+ autotool_version = $(shell printf '%s\n' /usr/local/bin/$1-* | egrep -o '[0-9][^-]+$$' | tail -n 1)
282
+ export AUTOCONF_VERSION := $(call autotool_version,autoconf)
283
+ export AUTOMAKE_VERSION := $(call autotool_version,automake)
284
+ endif
285
+
286
+ # ====== BUILD TARGETS ======
287
+
288
+ ## advpng
289
+ $(eval $(call depend,ADVPNG,LIBZ))
290
+ $(ADVPNG_TARGET) :
291
+ cd $(DIR) && ./configure LDFLAGS="$(XORIGIN)"
292
+ cd $(DIR) && $(MAKE) advpng
293
+ $(call chrpath_origin,$@)
294
+
295
+ ## gifsicle
296
+ $(GIFSICLE_TARGET) :
297
+ cd $(DIR) && ./configure
298
+ cd $(DIR) && $(MAKE) gifsicle
299
+
300
+ ## jhead
301
+ $(JHEAD_TARGET) :
302
+ cd $(DIR) && $(MAKE) jhead CC="$(CC) $(CFLAGS)"
303
+
304
+ ## jpeg-recompress
305
+ $(eval $(call depend-build,JPEG-RECOMPRESS,LIBMOZJPEG))
306
+ $(JPEG-RECOMPRESS_TARGET) :
307
+ cd $(DIR) && $(MAKE) jpeg-recompress CC="$(CC) $(CFLAGS)" LIBJPEG=$(LIBMOZJPEG_TARGET) \
308
+ MAKE=$(MAKE) # fix for bsd in jpeg-archive-2.1.1
309
+
310
+ ## jpegoptim
311
+ $(eval $(call depend,JPEGOPTIM,LIBJPEG))
312
+ $(JPEGOPTIM_TARGET) :
313
+ cd $(DIR) && ./configure LDFLAGS="$(XORIGIN)" --host $(HOST)
314
+ cd $(DIR) && $(MAKE) jpegoptim
315
+ $(call chrpath_origin,$@)
316
+
317
+ ## jpegtran
318
+ $(eval $(call depend,JPEGTRAN,LIBJPEG))
319
+ $(JPEGTRAN_TARGET) :
320
+ cd $(DIR) && $(MAKE) jpegtran LDFLAGS="$(XORIGIN)"
321
+ $(call chrpath_origin,$(JPEGTRAN_TARGET))
322
+
323
+ ## libjpeg
324
+ $(LIBJPEG_TARGET) :
325
+ cd $(DIR) && ./configure CC="$(CC) $(CFLAGS)"
326
+ cd $(DIR) && $(libtool_target_soname)
327
+ ifdef IS_DARWIN
328
+ cd $(DIR) && $(MAKE) libjpeg.la LDFLAGS="-Wl,-install_name,@loader_path/$(@F)"
329
+ else
330
+ cd $(DIR) && $(MAKE) libjpeg.la
331
+ endif
332
+ cd $(@D) && $(ln_s) .libs/libjpeg$(DLEXT) .
333
+
334
+ ## libmozjpeg
335
+ $(LIBMOZJPEG_TARGET) :
336
+ cd $(DIR) && autoreconf -fiv
337
+ cd $(DIR) && ./configure --host $(HOST)
338
+ cd $(DIR)/simd && $(MAKE)
339
+ cd $(DIR) && $(MAKE) libjpeg.la
340
+ cd $(DIR) && $(ln_s) .libs/libjpeg.a .
341
+
342
+ ## libpng
343
+ $(eval $(call depend,LIBPNG,LIBZ))
344
+ $(LIBPNG_TARGET) :
345
+ cd $(DIR) && ./configure CC="$(CC) $(CFLAGS)"
346
+ cd $(DIR) && $(pkgconfig_pwd) -- *.pc
347
+ cd $(DIR) && perl -pi -e 's/(?<=lpng)\d+//g' -- *.pc # %MAJOR%%MINOR% suffix
348
+ cd $(DIR) && $(libtool_target_soname)
349
+ ifdef IS_DARWIN
350
+ cd $(DIR) && $(MAKE) libpng16.la LDFLAGS="-Wl,-install_name,@loader_path/$(@F)"
351
+ else
352
+ cd $(DIR) && $(MAKE) libpng16.la LDFLAGS="$(XORIGIN)"
353
+ endif
354
+ cd $(DIR) && $(ln_s) .libs/libpng16$(DLEXT) libpng$(DLEXT)
355
+ $(call chrpath_origin,$@)
356
+
357
+ ## libz
358
+ ifdef IS_DARWIN
359
+ $(LIBZ_TARGET) : export LDSHARED = $(CC) -dynamiclib -install_name @loader_path/$(@F) -compatibility_version 1 -current_version $(LIBZ_VER)
360
+ else
361
+ $(LIBZ_TARGET) : export LDSHARED = $(CC) -shared -Wl,-soname,$(@F),--version-script,zlib.map
362
+ endif
363
+ $(LIBZ_TARGET) :
364
+ cd $(DIR) && ./configure
365
+ cd $(DIR) && $(pkgconfig_pwd) -- *.pc
366
+ cd $(DIR) && $(MAKE) placebo
367
+
368
+ ## optipng
369
+ $(eval $(call depend,OPTIPNG,LIBPNG LIBZ))
370
+ $(OPTIPNG_TARGET) :
371
+ cd $(DIR) && ./configure -with-system-libs
372
+ cd $(DIR) && $(MAKE) all LDFLAGS="$(XORIGIN) $(LDFLAGS)"
373
+ $(call chrpath_origin,$@)
374
+
375
+ ## pngcrush
376
+ $(eval $(call depend,PNGCRUSH,LIBPNG LIBZ))
377
+ $(PNGCRUSH_TARGET) :
378
+ cd $(DIR) && rm -f png.h pngconf.h
379
+ cd $(DIR) && $(MAKE) pngcrush \
380
+ CC="$(CC)" \
381
+ LD="$(CC)" \
382
+ LIBS="-lpng -lz -lm" \
383
+ CFLAGS="$(CFLAGS)" \
384
+ CPPFLAGS="$(CPPFLAGS)" \
385
+ LDFLAGS="$(XORIGIN) $(LDFLAGS)"
386
+ $(call chrpath_origin,$@)
387
+
388
+ ## pngquant
389
+ $(eval $(call depend,PNGQUANT,LIBPNG LIBZ))
390
+ $(PNGQUANT_TARGET) :
391
+ cd $(DIR) && ./configure --without-cocoa --extra-ldflags="$(XORIGIN)"
392
+ cd $(DIR) && $(MAKE) pngquant
393
+ $(call chrpath_origin,$@)