forked from serverlesspub/imagemagick-aws-lambda-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile_ImageMagick
260 lines (205 loc) · 6.09 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
LIBPNG_VERSION ?= 1.6.37
LIBJPG_VERSION ?= 9e
OPENJP2_VERSION ?= 2.5.0
LIBTIFF_VERSION ?= 4.4.0
BZIP2_VERSION ?= 1.0.6
LIBWEBP_VERSION ?= 1.2.3
IMAGEMAGICK_VERSION ?= 7.1.0-44
LIBHEIF_VERSION ?= 1.12.0
LIBDE265_VERSION ?= 1.0.8
LCMS_VERSION ?= 2.12
FREETYPE_VERSION ?= 2.12.1
HARFBUZZ_VERSION ?= 5.0.1
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)
## libde265
LIBDE265_SOURCE=libde265-$(LIBDE265_VERSION).tar.gz
$(LIBDE265_SOURCE):
curl -LO https://github.com/strukturag/libde265/releases/download/v$(LIBDE265_VERSION)/$(LIBDE265_SOURCE)
$(CACHE_DIR)/lib/libde265.a: $(LIBDE265_SOURCE)
tar xf $<
cd libde265*
./autogen.sh
$(CONFIGURE)
make
make install
## libheic
LIBHEIF_SOURCE=libheif-$(LIBHEIF_VERSION).tar.gz
$(LIBHEIF_SOURCE):
curl -LO https://github.com/strukturag/libheif/releases/download/v$(LIBHEIF_VERSION)/$(LIBHEIF_SOURCE)
$(CACHE_DIR)/lib/libheif.a: $(LIBHEIF_SOURCE)
tar xf $<
cd libheif*
./autogen.sh
$(CONFIGURE)
make
make install
## 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=$(CACHE_DIR)/lib/libpng.a
$(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
LIBBZ2=$(CACHE_DIR)/lib/libbz2.a
$(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
## LCMS
LCMS_SOURCE=lcms2-$(LCMS_VERSION).tar.gz
$(LCMS_SOURCE):
curl -L https://github.com/mm2/Little-CMS/releases/download/lcms$(LCMS_VERSION)/lcms2-$(LCMS_VERSION).tar.gz -o $(LCMS_SOURCE)
$(CACHE_DIR)/lib/liblcms2.a: $(LCMS_SOURCE)
tar xf $<
cd lcms2-*
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
## freetype and harfbuzz co-depend on each other, so freetype needs to be
## built without harfbuzz first, then harfbuzz with freetype, then freetype again
## see http://www.linuxfromscratch.org/blfs/view/svn/general/harfbuzz.html
FREETYPE_SOURCE=freetype-$(FREETYPE_VERSION).tar.gz
LIBFREETYPE=$(CACHE_DIR)/lib/libfreetype.a
HARFBUZZ_SOURCE=harfbuzz-$(HARFBUZZ_VERSION).tar.xz
LIBHARFBUZZ=$(CACHE_DIR)/lib/libharfbuzz.a
$(FREETYPE_SOURCE):
# curl -LO https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz
curl -LOk https://download.savannah.gnu.org/releases/freetype/$(FREETYPE_SOURCE)
$(HARFBUZZ_SOURCE):
curl -LO https://github.com/harfbuzz/harfbuzz/releases/download/$(HARFBUZZ_VERSION)/$(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) $(LIBPNG) $(LIBBZ2) $(LIBHARFBUZZ)
tar xf $<
cd freetype-$(FREETYPE_VERSION)
$(CONFIGURE) \
--without-harfbuzz \
--with-png \
--with-bzip2
make distclean clean
make
make install
## 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/libde265.a \
$(CACHE_DIR)/lib/libheif.a \
$(CACHE_DIR)/lib/liblcms2.a \
$(CACHE_DIR)/lib/libfreetype.a \
$(CACHE_DIR)/lib/libharfbuzz.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 -lstdc++" \
--disable-dependency-tracking \
--disable-shared \
--enable-static \
--with-freetype=yes \
--with-heic=yes \
--with-lcms=yes \
--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