aout: pass system play time to play callback
[vlc.git] / extras / tools / tools.mak
1 # Copyright (C) 2003-2011 the VideoLAN team
2 #
3 # This file is under the same license as the vlc package.
4
5 include packages.mak
6
7 #
8 # common rules
9 #
10
11 AUTOCONF=$(PREFIX)/bin/autoconf
12 export AUTOCONF
13
14 ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
15 download = curl -f -L -- "$(1)" > "$@.tmp" && touch $@.tmp && mv $@.tmp $@
16 else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
17 download = rm -f $@.tmp && \
18         wget --passive -c -p -O $@.tmp "$(1)" && \
19         touch $@.tmp && \
20         mv $@.tmp $@
21 else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
22 download = rm -f $@.tmp && \
23         fetch -p -o $@.tmp "$(1)" && \
24         touch $@.tmp && \
25         mv $@.tmp $@
26 else
27 download = $(error Neither curl nor wget found!)
28 endif
29
30 download_pkg = $(call download,$(VIDEOLAN)/$(2)/$(lastword $(subst /, ,$(@)))) || \
31         ( $(call download,$(1)) && echo "Please upload package $(lastword $(subst /, ,$(@))) to our FTP" )  \
32         && grep $(@) SHA512SUMS| shasum -a 512 -c
33
34 UNPACK = $(RM) -R $@ \
35     $(foreach f,$(filter %.tar.gz %.tgz,$^), && tar xvzf $(f)) \
36     $(foreach f,$(filter %.tar.bz2,$^), && tar xvjf $(f)) \
37     $(foreach f,$(filter %.tar.xz,$^), && tar xvJf $(f)) \
38     $(foreach f,$(filter %.zip,$^), && unzip $(f))
39
40 UNPACK_DIR = $(patsubst %.tar,%,$(basename $(notdir $<)))
41 APPLY = (cd $(UNPACK_DIR) && patch -p1) <
42 MOVE = mv $(UNPACK_DIR) $@ && touch $@
43
44 #
45 # package rules
46 #
47
48 # yasm
49
50 yasm-$(YASM_VERSION).tar.gz:
51         $(call download_pkg,$(YASM_URL),yasm)
52
53 yasm: yasm-$(YASM_VERSION).tar.gz
54         $(UNPACK)
55         $(MOVE)
56
57 .yasm: yasm
58         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
59         touch $@
60
61 CLEAN_FILE += .yasm
62 CLEAN_PKG += yasm
63 DISTCLEAN_PKG += yasm-$(YASM_VERSION).tar.gz
64
65 nasm-$(NASM_VERSION).tar.gz:
66         $(call download_pkg,$(NASM_URL),nasm)
67
68 nasm: nasm-$(NASM_VERSION).tar.gz
69         $(UNPACK)
70         $(MOVE)
71
72 .nasm: nasm
73         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
74         touch $@
75
76 CLEAN_FILE += .nasm
77 CLEAN_PKG += nasm
78 DISTCLEAN_PKG += nasm-$(NASM_VERSION).tar.gz
79
80 # cmake
81
82 cmake-$(CMAKE_VERSION).tar.gz:
83         $(call download_pkg,$(CMAKE_URL),cmake)
84
85 cmake: cmake-$(CMAKE_VERSION).tar.gz
86         $(UNPACK)
87         $(MOVE)
88
89 .cmake: cmake
90         (cd $<; ./configure --prefix=$(PREFIX) $(CMAKEFLAGS) && $(MAKE) && $(MAKE) install)
91         touch $@
92
93 CLEAN_FILE += .cmake
94 CLEAN_PKG += cmake
95 DISTCLEAN_PKG += cmake-$(CMAKE_VERSION).tar.gz
96
97 # libtool
98
99 libtool-$(LIBTOOL_VERSION).tar.gz:
100         $(call download_pkg,$(LIBTOOL_URL),libtool)
101
102 libtool: libtool-$(LIBTOOL_VERSION).tar.gz
103         $(UNPACK)
104         $(APPLY) libtool-2.4.2-bitcode.patch
105         $(APPLY) libtool-2.4.2-san.patch
106         $(APPLY) libtool-2.4.6-clang-libs.patch
107         $(MOVE)
108
109 .libtool: libtool .automake
110         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
111         ln -sf libtool $(PREFIX)/bin/glibtool
112         ln -sf libtoolize $(PREFIX)/bin/glibtoolize
113         touch $@
114
115 CLEAN_PKG += libtool
116 DISTCLEAN_PKG += libtool-$(LIBTOOL_VERSION).tar.gz
117 CLEAN_FILE += .libtool
118
119 # GNU tar (with xz support)
120
121 tar-$(TAR_VERSION).tar.bz2:
122         $(call download_pkg,$(TAR_URL),tar)
123
124 tar: tar-$(TAR_VERSION).tar.bz2
125         $(UNPACK)
126         $(MOVE)
127
128 .tar: tar
129         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
130         touch $@
131
132 CLEAN_PKG += tar
133 DISTCLEAN_PKG += tar-$(TAR_VERSION).tar.bz2
134 CLEAN_FILE += .tar
135
136 # xz
137
138 xz-$(XZ_VERSION).tar.bz2:
139         $(call download_pkg,$(XZ_URL),xz)
140
141 xz: xz-$(XZ_VERSION).tar.bz2
142         $(UNPACK)
143         $(MOVE)
144
145 .xz: xz
146         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install && rm $(PREFIX)/lib/pkgconfig/liblzma.pc)
147         touch $@
148
149 CLEAN_PKG += xz
150 DISTCLEAN_PKG += xz-$(XZ_VERSION).tar.bz2
151 CLEAN_FILE += .xz
152
153 # autoconf
154
155 autoconf-$(AUTOCONF_VERSION).tar.gz:
156         $(call download_pkg,$(AUTOCONF_URL),autoconf)
157
158 autoconf: autoconf-$(AUTOCONF_VERSION).tar.gz
159         $(UNPACK)
160         $(MOVE)
161
162 .autoconf: autoconf .pkg-config
163         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
164         touch $@
165
166 CLEAN_FILE += .autoconf
167 CLEAN_PKG += autoconf
168 DISTCLEAN_PKG += autoconf-$(AUTOCONF_VERSION).tar.gz
169
170 # automake
171
172 automake-$(AUTOMAKE_VERSION).tar.gz:
173         $(call download_pkg,$(AUTOMAKE_URL),automake)
174
175 automake: automake-$(AUTOMAKE_VERSION).tar.gz
176         $(UNPACK)
177         $(MOVE)
178
179 .automake: automake .autoconf
180         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
181         touch $@
182
183 CLEAN_FILE += .automake
184 CLEAN_PKG += automake
185 DISTCLEAN_PKG += automake-$(AUTOMAKE_VERSION).tar.gz
186
187 # m4
188
189 m4-$(M4_VERSION).tar.gz:
190         $(call download_pkg,$(M4_URL),m4)
191
192 m4: m4-$(M4_VERSION).tar.gz
193         $(UNPACK)
194         $(APPLY) bison-macOS-c41f233c.patch
195         $(APPLY) bison-macOS-7df04f9.patch
196         $(MOVE)
197
198 .m4: m4
199         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
200         touch $@
201
202 CLEAN_FILE += .m4
203 CLEAN_PKG += m4
204 DISTCLEAN_PKG += m4-$(M4_VERSION).tar.gz
205
206 # pkg-config
207
208 pkg-config-$(PKGCFG_VERSION).tar.gz:
209         $(call download_pkg,$(PKGCFG_URL),pkgconfiglite)
210
211 pkgconfig: pkg-config-$(PKGCFG_VERSION).tar.gz
212         $(UNPACK)
213         mv pkg-config-lite-$(PKGCFG_VERSION) pkg-config-$(PKGCFG_VERSION)
214         $(MOVE)
215
216 .pkg-config: pkgconfig
217         (cd pkgconfig; ./configure --prefix=$(PREFIX) --disable-shared --enable-static && $(MAKE) && $(MAKE) install)
218         touch $@
219
220 CLEAN_FILE += .pkg-config
221 CLEAN_PKG += pkgconfig
222 DISTCLEAN_PKG += pkg-config-$(PKGCFG_VERSION).tar.gz
223
224 # gas-preprocessor
225 gas-preprocessor-$(GAS_VERSION).tar.gz:
226         $(call download_pkg,$(GAS_URL),gas-preprocessor)
227
228 gas: gas-preprocessor-$(GAS_VERSION).tar.gz
229         $(UNPACK)
230         $(MOVE)
231
232 .gas: gas
233         mkdir -p $(PREFIX)/bin
234         cp gas/gas-preprocessor.pl $(PREFIX)/bin/
235         touch $@
236
237 CLEAN_FILE += .gas
238 CLEAN_PKG += gas
239 DISTCLEAN_PKG += gas-preprocessor-$(GAS_VERSION).tar.gz
240
241 # Ragel State Machine Compiler
242 ragel-$(RAGEL_VERSION).tar.gz:
243         $(call download_pkg,$(RAGEL_URL),ragel)
244
245 ragel: ragel-$(RAGEL_VERSION).tar.gz
246         $(UNPACK)
247         $(APPLY) ragel-6.8-javacodegen.patch
248         $(MOVE)
249
250
251 .ragel: ragel
252         (cd ragel; ./configure --prefix=$(PREFIX) --disable-shared --enable-static && $(MAKE) && $(MAKE) install)
253         touch $@
254
255 CLEAN_FILE += .ragel
256 CLEAN_PKG += ragel
257 DISTCLEAN_PKG += ragel-$(RAGEL_VERSION).tar.gz
258
259 # GNU sed
260
261 sed-$(SED_VERSION).tar.bz2:
262         $(call download_pkg,$(SED_URL),sed)
263
264 sed: sed-$(SED_VERSION).tar.bz2
265         $(UNPACK)
266         $(MOVE)
267
268 .sed: sed
269         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
270         touch $@
271
272 CLEAN_PKG += sed
273 DISTCLEAN_PKG += sed-$(SED_VERSION).tar.bz2
274 CLEAN_FILE += .sed
275
276 # Apache ANT
277
278 apache-ant-$(ANT_VERSION).tar.bz2:
279         $(call download_pkg,$(ANT_URL),ant)
280
281 ant: apache-ant-$(ANT_VERSION).tar.bz2
282         $(UNPACK)
283         $(MOVE)
284
285 .ant: ant
286         (mkdir -p $(PREFIX)/bin && cp $</bin/* $(PREFIX)/bin/)
287         (mkdir -p $(PREFIX)/lib && cp $</lib/* $(PREFIX)/lib/)
288         touch $@
289
290 CLEAN_PKG += ant
291 DISTCLEAN_PKG += apache-ant-$(ANT_VERSION).tar.bz2
292 CLEAN_FILE += .ant
293
294
295 # Protobuf Protoc
296
297 protobuf-$(PROTOBUF_VERSION).tar.gz:
298         $(call download_pkg,$(PROTOBUF_URL),protobuf)
299
300 protobuf: protobuf-$(PROTOBUF_VERSION).tar.gz
301         $(UNPACK)
302         $(MOVE)
303
304 .protoc: protobuf
305         (cd $< && ./configure --prefix="$(PREFIX)" --disable-shared --enable-static && $(MAKE) && $(MAKE) install)
306         (find $(PREFIX) -name 'protobuf*.pc' -exec rm -f {} \;)
307         touch $@
308
309 CLEAN_PKG += protobuf
310 DISTCLEAN_PKG += protobuf-$(PROTOBUF_VERSION).tar.gz
311 CLEAN_FILE += .protoc
312
313 #
314 # GNU bison
315 #
316
317 bison-$(BISON_VERSION).tar.xz:
318         $(call download_pkg,$(BISON_URL),bison)
319
320 bison: bison-$(BISON_VERSION).tar.xz
321         $(UNPACK)
322         $(APPLY) bison-macOS-c41f233c.patch
323         $(APPLY) bison-macOS-7df04f9.patch
324         $(MOVE)
325
326 .bison: bison
327         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
328         touch $@
329
330 CLEAN_PKG += bison
331 DISTCLEAN_PKG += bison-$(BISON_VERSION).tar.xz
332 CLEAN_FILE += .bison
333
334 #
335 # GNU flex
336 #
337
338 flex-$(FLEX_VERSION).tar.gz:
339         $(call download_pkg,$(FLEX_URL),flex)
340
341 flex: flex-$(FLEX_VERSION).tar.gz
342         $(UNPACK)
343         $(MOVE)
344
345 .flex: flex
346         (cd $<; ./configure --prefix=$(PREFIX) && $(MAKE) && $(MAKE) install)
347         touch $@
348
349 CLEAN_PKG += flex
350 DISTCLEAN_PKG += flex-$(FLEX_VERSION).tar.gz
351 CLEAN_FILE += .flex
352
353
354 #
355 #
356 #
357
358 fetch-all: $(DISTCLEAN_PKG)
359
360 clean:
361         rm -fr $(CLEAN_FILE) $(CLEAN_PKG) build/
362
363 distclean: clean
364         rm -fr $(DISTCLEAN_PKG)
365
366 .PHONY: all clean distclean
367
368 .DELETE_ON_ERROR: