forked from ashtons/libtiff-ios
/
Makefile
198 lines (160 loc) · 6.95 KB
/
Makefile
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
PNG_NAME := libpng-1.6.21
JPEG_SRC_NAME := jpegsrc.v9a# filename at the server
JPEG_DIR_NAME := jpeg-9a# folder name after the JPEG_SRC_NAME archive has been unpacked
TIFF_NAME := tiff-4.0.4
SDK_IPHONEOS_PATH=$(shell xcrun --sdk iphoneos --show-sdk-path)
SDK_IPHONESIMULATOR_PATH=$(shell xcrun --sdk iphonesimulator --show-sdk-path)
XCODE_DEVELOPER_PATH="`xcode-select -p`"
XCODETOOLCHAIN_PATH=$(XCODE_DEVELOPER_PATH)/Toolchains/XcodeDefault.xctoolchain
IOS_DEPLOY_TGT="7.0"
IMAGE_SRC = $(shell pwd)
PNG_SRC = $(IMAGE_SRC)/$(PNG_NAME)
JPEG_SRC = $(IMAGE_SRC)/$(JPEG_DIR_NAME)
TIFF_SRC = $(IMAGE_SRC)/$(TIFF_NAME)
IMAGE_LIB_DIR = $(shell pwd)/dependencies/lib/
IMAGE_INC_DIR = $(shell pwd)/dependencies/include/
LIB_FAT_DIR = $(shell pwd)/dependencies/lib
libpngfiles = libpng.a
libjpegfiles = libjpeg.a
libtifffiles = libtiff.a libtiffxx.a
sdks = $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONEOS_PATH) $(SDK_IPHONESIMULATOR_PATH) $(SDK_IPHONESIMULATOR_PATH)
archs_all = armv7 armv7s arm64 i386 x86_64
arch_names_all = arm-apple-darwin7 arm-apple-darwin7s arm-apple-darwin64 i386-apple-darwin x86_64-apple-darwin
arch_names = $(foreach arch, $(ARCHS), $(call swap, $(arch), $(archs_all), $(arch_names_all) ) )
ARCHS ?= $(archs_all)
libpngfolders = $(foreach arch, $(arch_names), $(PNG_SRC)/$(arch)/)
libjpegfolders = $(foreach arch, $(arch_names), $(JPEG_SRC)/$(arch)/)
libtifffolders = $(foreach arch, $(arch_names), $(TIFF_SRC)/$(arch)/)
libpngfolders_all = $(foreach arch, $(arch_names_all), $(PNG_SRC)/$(arch)/)
libjpegfolders_all = $(foreach arch, $(arch_names_all), $(JPEG_SRC)/$(arch)/)
libtifffolders_all = $(foreach arch, $(arch_names_all), $(TIFF_SRC)/$(arch)/)
libpngmakefile = $(foreach folder, $(libpngfolders), $(addprefix $(folder), Makefile) )
libjpegmakefile = $(foreach folder, $(libjpegfolders), $(addprefix $(folder), Makefile) )
libtiffmakefile = $(foreach folder, $(libtifffolders), $(addprefix $(folder), Makefile) )
libpngfat = $(addprefix $(IMAGE_LIB_DIR), $(libpngfiles))
libjpegfat = $(addprefix $(IMAGE_LIB_DIR), $(libjpegfiles))
libtifffat = $(addprefix $(IMAGE_LIB_DIR), $(libtifffiles))
libpng = $(foreach folder, $(libpngfolders), $(addprefix $(folder)/lib/, $(libpngfiles)) )
libjpeg = $(foreach folder, $(libjpegfolders), $(addprefix $(folder)/lib/, $(libjpegfiles)) )
libtiff = $(foreach folder, $(libtifffolders), $(addprefix $(folder)/lib/, $(libtifffiles)) )
libpngconfig = $(PNG_SRC)/configure
libjpegconfig = $(JPEG_SRC)/configure
libtiffconfig = $(TIFF_SRC)/configure
index = $(words $(shell a="$(2)";echo $${a/$(1)*/$(1)} ))
swap = $(word $(call index,$(1),$(2)),$(3))
dependant_libs = libpng libjpeg libtiff
.PHONY : all
all : $(dependant_libs)
#######################
# Build libtiff and all of it's dependencies
#######################
libtiff : $(libtifffat)
$(libtifffat) : $(libtiff)
mkdir -p $(@D)
xcrun lipo $(realpath $(addsuffix lib/$(@F), $(libtifffolders_all)) ) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libtifffolders))/include/*.h $(IMAGE_INC_DIR)
$(libtiff) : $(libtiffmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -sj8 && $(MAKE) install
$(TIFF_SRC)/%/Makefile : $(libtiffconfig)
export SDKROOT="$(call swap, $*, $(arch_names_all), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names_all), $(archs_all)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2 -fembed-bitcode" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-fast-install --enable-shared=no --prefix=`pwd` --without-x --with-jpeg-include-dir=$(abspath $(@D)/../../$(JPEG_DIR_NAME)/$*/include) --with-jpeg-lib-dir=$(abspath $(@D)/../../$(JPEG_DIR_NAME)/$*/lib)
libpng : $(libpngfat)
$(libpngfat) : $(libpng)
mkdir -p $(@D)
xcrun lipo $(realpath $(addsuffix lib/$(@F), $(libpngfolders_all)) ) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libpngfolders))/include/*.h $(IMAGE_INC_DIR)
$(libpng) : $(libpngmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -sj8 && $(MAKE) install
$(PNG_SRC)/%/Makefile : $(libpngconfig)
export SDKROOT="$(call swap, $*, $(arch_names_all), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names_all), $(archs_all)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2 -fembed-bitcode" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-shared=no --prefix=`pwd`
libjpeg : $(libjpegfat)
$(libjpegfat) : $(libjpeg)
mkdir -p $(@D)
xcrun lipo $(realpath $(addsuffix lib/$(@F), $(libjpegfolders_all)) ) -create -output $@
mkdir -p $(IMAGE_INC_DIR)
cp -rvf $(firstword $(libjpegfolders))/include/*.h $(IMAGE_INC_DIR)
$(libjpeg) : $(libjpegmakefile)
cd $(abspath $(@D)/..) ; \
$(MAKE) -sj8 && $(MAKE) install
$(JPEG_SRC)/%/Makefile : $(libjpegconfig)
export SDKROOT="$(call swap, $*, $(arch_names_all), $(sdks))" ; \
export CFLAGS="-Qunused-arguments -arch $(call swap, $*, $(arch_names_all), $(archs_all)) -pipe -no-cpp-precomp -isysroot $$SDKROOT -miphoneos-version-min=$(IOS_DEPLOY_TGT) -O2 -fembed-bitcode" ; \
export CPPFLAGS=$$CFLAGS ; \
export CXXFLAGS="$$CFLAGS -Wno-deprecated-register"; \
mkdir -p $(@D) ; \
cd $(@D) ; \
../configure --host=$* --enable-shared=no --prefix=`pwd`
#######################
# Download sources
#######################
$(libtiffconfig) :
curl ftp://ftp.remotesensing.org/pub/libtiff/$(TIFF_NAME).tar.gz | tar -xpf-
$(libjpegconfig) :
curl http://www.ijg.org/files/$(JPEG_SRC_NAME).tar.gz | tar -xpf-
$(libpngconfig) :
curl ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng16/$(PNG_NAME).tar.gz | tar -xpf-
#######################
# Clean
#######################
.PHONY : clean
clean : cleanpng cleantiff cleanjpeg
.PHONY : cleanpng
cleanpng :
for folder in $(realpath $(libpngfolders_all) ); do \
cd $$folder; \
$(MAKE) clean; \
done
.PHONY : cleanjpeg
cleanjpeg :
for folder in $(realpath $(libjpegfolders_all) ); do \
cd $$folder; \
$(MAKE) clean; \
done
.PHONY : cleantiff
cleantiff :
for folder in $(realpath $(libtifffolders_all) ); do \
cd $$folder; \
$(MAKE) clean; \
done
.PHONY : mostlyclean
mostlyclean : mostlycleanpng mostlycleantiff mostlycleanjpeg
.PHONY : mostlycleanpng
mostlycleanpng :
for folder in $(realpath $(libpngfolders) ); do \
cd $$folder; \
$(MAKE) mostlyclean; \
done
.PHONY : mostlycleantiff
mostlycleantiff :
for folder in $(realpath $(libtifffolders_all) ); do \
cd $$folder; \
$(MAKE) mostlyclean; \
done
.PHONY : mostlycleanjpeg
mostlycleanjpeg :
for folder in $(realpath $(libjpegfolders_all) ); do \
cd $$folder; \
$(MAKE) mostlyclean; \
done
.PHONY : distclean
distclean :
-rm -rf $(IMAGE_LIB_DIR)
-rm -rf $(IMAGE_INC_DIR)
-rm -rf $(PNG_SRC)
-rm -rf $(JPEG_SRC)
-rm -rf $(TIFF_SRC)