forked from thecfguy/imagemagick-aws-lambda-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_ImageMagick
293 lines (230 loc) · 6.78 KB
/
Makefile_ImageMagick
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
LIBPNG_VERSION ?= 1.6.37
LIBJPG_VERSION ?= 9c
OPENJP2_VERSION ?= 2.3.1
LIBTIFF_VERSION ?= 4.0.9
BZIP2_VERSION ?= 1.0.6
LIBWEBP_VERSION ?= 0.6.1
IMAGEMAGICK_VERSION ?= 7.0.8-45
UTIL_LINUX_VERSION ?= 2.33
LIBJPEG_VERSION ?= 9c
LIBXML2_VERSION ?= 2.9.9
GLIB_VERSION ?= 2.58.3
CAIRO_VERSION ?= 1.14.8
LIBCROCO_VERSION ?= 0.6.8
PANGO_VERSION ?= 1.28.4
GDK_PIXBUF_VERSION ?= 2.28.2
LIBFFI_VERSION ?= 3.2.1
LIBRSVG_VERSION ?= 2.26.3
PIXMAN_VERSION ?= 0.38.4
FONTCONFIG_VERSION ?= 2.13.0
FREETYPE_VERSION ?= 2.10.0
HARFBUZZ_VERSION ?= 2.4.0
TARGET_DIR ?= /opt/
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
CACHE_DIR=$(PROJECT_ROOT)build/cache
.ONESHELL:
CONFIGURE = PKG_CONFIG_PATH=$(CACHE_DIR)/lib/pkgconfig \
./configure \
CPPFLAGS=-I$(CACHE_DIR)/include \
LDFLAGS=-L$(CACHE_DIR)/lib \
--disable-dependency-tracking \
--disable-shared \
--enable-static \
--prefix=$(CACHE_DIR)
## dev tool istallation
init:
yum install -y gcc gcc-c++ cmake3 intltool flex bison shared-mime-info gperf
## ============== begin new 1 ==========
## util-linux has libmount and libuuid etc
LIBUUID=$(CACHE_DIR)/lib/libuuid.a
UTIL_LINUX_SOURCE=util-linux-$(UTIL_LINUX_VERSION).tar.xz
$(UTIL_LINUX_SOURCE):
curl -LO https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v$(UTIL_LINUX_VERSION)/$(UTIL_LINUX_SOURCE)
$(LIBUUID): $(UTIL_LINUX_SOURCE)
tar xf $<
cd util-linux*
$(CONFIGURE) \
--disable-all-programs \
--enable-libuuid
make
make install
## libxml2
LIBXML2_SOURCE=libxml2-$(LIBXML2_VERSION).tar.gz
LIBXML2=$(CACHE_DIR)/lib/libxml2.a
$(LIBXML2_SOURCE):
curl -LO ftp://xmlsoft.org/libxml2/$(LIBXML2_SOURCE)
$(LIBXML2): $(LIBXML2_SOURCE)
tar xf $<
cd libxml2*
$(CONFIGURE) \
--without-history \
--without-python
make
make install
## licroco
LIBCROCO_SOURCE=libcroco-$(LIBCROCO_VERSION).tar.xz
LIBCROCO_MINOR_VERSION=$(basename $(LIBCROCO_VERSION))
LIBCROCO=$(CACHE_DIR)/lib/libcroco-$(LIBCROCO_MINOR_VERSION).a
$(LIBCROCO_SOURCE):
curl -OL http://ftp.gnome.org/pub/GNOME/sources/libcroco/$(LIBCROCO_MINOR_VERSION)/$(LIBCROCO_SOURCE)
$(LIBCROCO): $(LIBCROCO_SOURCE) $(LIBXML2) $(GLIB)
tar xf $<
cd libcroco*
$(CONFIGURE) \
--disable-gtk-doc \
--disable-gtk-doc-html
make
make install
## ============== end new 1 ============
## libjpg
LIBJPG_SOURCE=jpegsrc.v$(LIBJPG_VERSION).tar.gz
$(LIBJPG_SOURCE):
curl -LO http://ijg.org/files/$(LIBJPG_SOURCE)
$(CACHE_DIR)/lib/libjpeg.a: $(LIBJPG_SOURCE)
tar xf $<
cd jpeg*
$(CONFIGURE)
make
make install
## libpng
LIBPNG_SOURCE=libpng-$(LIBPNG_VERSION).tar.xz
$(LIBPNG_SOURCE):
curl -LO http://prdownloads.sourceforge.net/libpng/$(LIBPNG_SOURCE)
$(CACHE_DIR)/lib/libpng.a: $(LIBPNG_SOURCE)
tar xf $<
cd libpng*
$(CONFIGURE)
make
make install
# libbz2
BZIP2_SOURCE=bzip2-$(BZIP2_VERSION).tar.gz
$(BZIP2_SOURCE):
curl -LO http://prdownloads.sourceforge.net/bzip2/bzip2-$(BZIP2_VERSION).tar.gz
$(CACHE_DIR)/lib/libbz2.a: $(BZIP2_SOURCE)
tar xf $<
cd bzip2-*
make libbz2.a
make install PREFIX=$(CACHE_DIR)
# libtiff
LIBTIFF_SOURCE=tiff-$(LIBTIFF_VERSION).tar.gz
$(LIBTIFF_SOURCE):
curl -LO http://download.osgeo.org/libtiff/$(LIBTIFF_SOURCE)
$(CACHE_DIR)/lib/libtiff.a: $(LIBTIFF_SOURCE) $(CACHE_DIR)/lib/libjpeg.a
tar xf $<
cd tiff-*
$(CONFIGURE)
make
make install
# libwebp
LIBWEBP_SOURCE=libwebp-$(LIBWEBP_VERSION).tar.gz
$(LIBWEBP_SOURCE):
curl -L https://github.com/webmproject/libwebp/archive/v$(LIBWEBP_VERSION).tar.gz -o $(LIBWEBP_SOURCE)
$(CACHE_DIR)/lib/libwebp.a: $(LIBWEBP_SOURCE)
tar xf $<
cd libwebp-*
sh autogen.sh
$(CONFIGURE)
make
make install
## libopenjp2
OPENJP2_SOURCE=openjp2-$(OPENJP2_VERSION).tar.gz
$(OPENJP2_SOURCE):
curl -L https://github.com/uclouvain/openjpeg/archive/v$(OPENJP2_VERSION).tar.gz -o $(OPENJP2_SOURCE)
$(CACHE_DIR)/lib/libopenjp2.a: $(OPENJP2_SOURCE) $(CACHE_DIR)/lib/libpng.a $(CACHE_DIR)/lib/libtiff.a
tar xf $<
cd openjpeg-*
mkdir -p build
cd build
PKG_CONFIG_PATH=$(CACHE_DIR)/lib/pkgconfig cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$(CACHE_DIR) \
-DBUILD_SHARED_LIBS:bool=off \
-DBUILD_CODEC:bool=off
make clean
make install
## =============== begin new ===================
FREETYPE_SOURCE=freetype-$(FREETYPE_VERSION).tar.gz
LIBFREETYPE=$(CACHE_DIR)/lib/libfreetype.a
HARFBUZZ_SOURCE=harfbuzz-$(HARFBUZZ_VERSION).tar.bz2
LIBHARFBUZZ=$(CACHE_DIR)/lib/libharfbuzz.a
$(FREETYPE_SOURCE):
curl -LO https://download.savannah.gnu.org/releases/freetype/$(FREETYPE_SOURCE)
$(HARFBUZZ_SOURCE):
curl -LO https://www.freedesktop.org/software/harfbuzz/release/$(HARFBUZZ_SOURCE)
FT_WITHOUT_HB_DIR=$(PROJECT_ROOT)build/freetype-$(FREETYPE_VERSION)-without-harfbuzz
FT_WITHOUT_HB=$(FT_WITHOUT_HB_DIR)/objs/.libs/libfreetype.a
$(FT_WITHOUT_HB): $(FREETYPE_SOURCE)
tar xf $< -C /tmp
rm -rf $(FT_WITHOUT_HB_DIR)
mv /tmp/freetype-$(FREETYPE_VERSION) $(FT_WITHOUT_HB_DIR)
cd $(FT_WITHOUT_HB_DIR)
$(CONFIGURE) --without-harfbuzz
make
make install
$(LIBHARFBUZZ): $(HARFBUZZ_SOURCE) $(FT_WITHOUT_HB)
tar xf $<
cd harfbuzz-$(HARFBUZZ_VERSION)
$(CONFIGURE) \
--with-freetype
make
make install
$(LIBFREETYPE): $(FREETYPE_SOURCE) $(GLIB) $(LIBPNG) $(LIBBZ2) $(LIBHARFBUZZ)
tar xf $<
cd freetype-$(FREETYPE_VERSION)
$(CONFIGURE) \
--with-harfbuzz \
--with-png \
--with-bzip2
yum install -y gperf
make distclean clean
make
make install
## fontconfig
FONTCONFIG_SOURCE=fontconfig-$(FONTCONFIG_VERSION).tar.bz2
LIBFONTCONFIG=$(CACHE_DIR)/lib/libfontconfig.a
$(FONTCONFIG_SOURCE):
curl -LO https://www.freedesktop.org/software/fontconfig/release/$(FONTCONFIG_SOURCE)
fontconfig $(LIBFONTCONFIG): $(FONTCONFIG_SOURCE) $(LIBXML2) $(LIBFREETYPE) $(LIBUUID)
tar xf $<
cd fontconfig-$(FONTCONFIG_VERSION)
$(CONFIGURE) --enable-libxml2
make
make install
## =============== end new =====================
## ImageMagick
IMAGE_MAGICK_SOURCE=ImageMagick-$(IMAGEMAGICK_VERSION).tar.gz
$(IMAGE_MAGICK_SOURCE):
curl -L https://github.com/ImageMagick/ImageMagick/archive/$(IMAGEMAGICK_VERSION).tar.gz -o $(IMAGE_MAGICK_SOURCE)
LIBS:=$(CACHE_DIR)/lib/libjpeg.a \
$(CACHE_DIR)/lib/libpng.a \
$(CACHE_DIR)/lib/libopenjp2.a \
$(CACHE_DIR)/lib/libtiff.a \
$(CACHE_DIR)/lib/libbz2.a \
$(CACHE_DIR)/lib/libwebp.a \
$(CACHE_DIR)/lib/libuuid.a \
$(CACHE_DIR)/lib/libfreetype.a \
$(CACHE_DIR)/lib/libharfbuzz.a \
$(CACHE_DIR)/lib/libfontconfig.a
$(TARGET_DIR)/bin/identify: $(IMAGE_MAGICK_SOURCE) $(LIBS)
tar xf $<
cd ImageMa*
PKG_CONFIG_PATH=$(CACHE_DIR)/lib/pkgconfig \
./configure \
CPPFLAGS=-I$(CACHE_DIR)/include \
LDFLAGS=-L$(CACHE_DIR)/lib \
--disable-dependency-tracking \
--disable-shared \
--enable-static \
--prefix=$(TARGET_DIR) \
--enable-delegate-build \
--without-modules \
--disable-docs \
--without-magick-plus-plus \
--without-perl \
--without-x \
--disable-openmp
make clean
make all
make install
libs: $(LIBS)
all: $(TARGET_DIR)/bin/identify