1 # Main makefile for VLC 3rd party libraries ("contrib")
2 # Copyright (C) 2003-2011 the VideoLAN team
4 # This file is under the same license as the vlc package.
8 # bootstrap configuration
11 TOPSRC ?
= ..
/..
/contrib
14 TARBALLS
:= $(TOPSRC
)/tarballs
16 PATH
:=$(abspath ..
/..
/extras
/tools
/build
/bin
):$(PATH
)
19 PKGS_ALL
:= $(patsubst $(SRC
)/%/rules.mak
,%,$(wildcard $(SRC
)/*/rules.mak
))
20 DATE
:= $(shell date
+%Y
%m
%d
)
23 # Common download locations
24 GNU ?
= http
://ftp.gnu.org
/gnu
25 SF
:= http
://heanet.dl.sourceforge.net
/sourceforge
26 VIDEOLAN
:= http
://downloads.videolan.org
/pub
/videolan
27 CONTRIB_VIDEOLAN
:= http
://downloads.videolan.org
/pub
/contrib
30 # Machine-dependent variables
33 PREFIX ?
= $(TOPDST
)/$(HOST
)
34 PREFIX
:= $(abspath
$(PREFIX
))
35 BUILDPREFIX ?
= $(TOPDST
)
36 BUILDPREFIX
:= $(abspath
$(BUILDPREFIX
))
37 BUILDBINDIR ?
= $(BUILDPREFIX
)/bin
38 ifneq ($(HOST
),$(BUILD
))
39 HAVE_CROSS_COMPILE
= 1
41 ARCH
:= $(shell $(SRC
)/get-arch.sh
$(HOST
))
43 ifeq ($(ARCH
)-$(HAVE_WIN32
),x86_64-1
)
47 ifdef HAVE_CROSS_COMPILE
50 need_pkg
= $(shell $(PKG_CONFIG
) $(1) || echo
1)
54 # Default values for tools
56 ifndef HAVE_CROSS_COMPILE
57 ifneq ($(findstring $(origin CC
),undefined default
),)
60 ifneq ($(findstring $(origin CXX
),undefined default
),)
63 ifneq ($(findstring $(origin LD
),undefined default
),)
66 ifneq ($(findstring $(origin AR
),undefined default
),)
69 ifneq ($(findstring $(origin RANLIB
),undefined default
),)
72 ifneq ($(findstring $(origin STRIP
),undefined default
),)
75 ifneq ($(findstring $(origin WIDL
),undefined default
),)
79 ifneq ($(findstring $(origin CC
),undefined default
),)
82 ifneq ($(findstring $(origin CXX
),undefined default
),)
85 ifneq ($(findstring $(origin LD
),undefined default
),)
88 ifneq ($(findstring $(origin AR
),undefined default
),)
91 ifneq ($(findstring $(origin RANLIB
),undefined default
),)
92 RANLIB
:= $(HOST
)-ranlib
94 ifneq ($(findstring $(origin STRIP
),undefined default
),)
95 STRIP
:= $(HOST
)-strip
97 ifneq ($(findstring $(origin WIDL
),undefined default
),)
115 EXTRA_CFLAGS
+= -isysroot
$(MACOSX_SDK
) -mmacosx-version-min
=$(MIN_OSX_VERSION
) -DMACOSX_DEPLOYMENT_TARGET
=$(MIN_OSX_VERSION
)
116 EXTRA_CXXFLAGS
+= -stdlib
=libc
++
117 EXTRA_LDFLAGS
+= -Wl
,-syslibroot
,$(MACOSX_SDK
) -mmacosx-version-min
=$(MIN_OSX_VERSION
) -isysroot
$(MACOSX_SDK
) -DMACOSX_DEPLOYMENT_TARGET
=$(MIN_OSX_VERSION
)
118 ifeq ($(ARCH
),x86_64
)
120 EXTRA_LDFLAGS
+= -m64
123 EXTRA_LDFLAGS
+= -m32
126 XCODE_FLAGS
= MACOSX_DEPLOYMENT_TARGET
=$(MIN_OSX_VERSION
) -sdk macosx
$(OSX_VERSION
) -arch
$(ARCH
)
136 AS
=perl
$(abspath ..
/..
/extras
/tools
/build
/bin
/gas-preprocessor.pl
) $(CC
)
137 CCAS
=gas-preprocessor.pl
$(CC
) -c
145 EXTRA_CFLAGS
+= $(CFLAGS
)
146 EXTRA_LDFLAGS
+= $(LDFLAGS
)
150 ifneq ($(shell $(CC
) $(CFLAGS
) -E
-dM
-include _mingw.h
- < /dev
/null | grep
-E __MINGW64_VERSION_MAJOR
),)
156 ifeq ($(ARCH
),x86_64
)
158 EXTRA_LDFLAGS
+= -m64
161 EXTRA_LDFLAGS
+= -m32
165 cppcheck
= $(shell $(CC
) $(CFLAGS
) -E
-dM
- < /dev
/null | grep
-E
$(1))
167 EXTRA_CFLAGS
+= -I
$(PREFIX
)/include
168 CPPFLAGS
:= $(CPPFLAGS
) $(EXTRA_CFLAGS
)
169 CFLAGS
:= $(CFLAGS
) $(EXTRA_CFLAGS
) -g
170 CXXFLAGS
:= $(CXXFLAGS
) $(EXTRA_CFLAGS
) $(EXTRA_CXXFLAGS
) -g
171 EXTRA_LDFLAGS
+= -L
$(PREFIX
)/lib
172 LDFLAGS
:= $(LDFLAGS
) $(EXTRA_LDFLAGS
)
174 ifndef WITH_OPTIMIZATION
175 CFLAGS
:= $(CFLAGS
) -O0
176 CXXFLAGS
:= $(CXXFLAGS
) -O0
178 CFLAGS
:= $(CFLAGS
) -O2
179 CXXFLAGS
:= $(CXXFLAGS
) -O2
182 # Do not export those! Use HOSTVARS.
184 # Do the FPU detection, after we have figured out our compilers and flags.
185 ifneq ($(findstring $(ARCH
),aarch64 i386 ppc ppc64 sparc sparc64 x86_64
),)
186 # This should be consistent with include/vlc_cpu.h
188 else ifneq ($(findstring $(ARCH
),arm
),)
189 ifneq ($(call cppcheck
, __VFP_FP__
)),)
190 ifeq ($(call cppcheck
, __SOFTFP__
),)
194 else ifneq ($(call cppcheck
, __mips_hard_float
),)
198 ACLOCAL_AMFLAGS
+= -I
$(PREFIX
)/share
/aclocal
199 export ACLOCAL_AMFLAGS
205 PKG_CONFIG ?
= pkg-config
206 ifdef HAVE_CROSS_COMPILE
207 # This inhibits .pc file from within the cross-compilation toolchain sysroot.
208 # Hopefully, nobody ever needs that.
209 PKG_CONFIG_PATH
:= /usr
/share
/pkgconfig
210 PKG_CONFIG_LIBDIR
:= /usr
/$(HOST
)/lib
/pkgconfig
211 export PKG_CONFIG_LIBDIR
213 PKG_CONFIG_PATH
:= $(PREFIX
)/lib
/pkgconfig
:$(PKG_CONFIG_PATH
)
214 export PKG_CONFIG_PATH
217 ifeq ($(shell git
--version
>/dev
/null
2>&1 || echo FAIL
),)
221 GIT ?
= $(error git not found
!)
224 ifeq ($(shell svn
--version
>/dev
/null
2>&1 || echo FAIL
),)
228 SVN ?
= $(error subversion client
(svn
) not found
!)
230 ifeq ($(shell curl
--version
>/dev
/null
2>&1 || echo FAIL
),)
231 download
= curl
-f
-L
-- "$(1)" > "$@"
232 else ifeq ($(shell wget
--version
>/dev
/null
2>&1 || echo FAIL
),)
233 download
= (rm -f
$@.tmp
&& \
234 wget
--passive
-c
-p
-O
$@.tmp
"$(1)" && \
237 else ifeq ($(which fetch
>/dev
/null
2>&1 || echo FAIL
),)
238 download
= (rm -f
$@.tmp
&& \
239 fetch
-p
-o
$@.tmp
"$(1)" && \
243 download
= $(error Neither curl nor wget found
!)
246 download_pkg
= $(call download
,$(CONTRIB_VIDEOLAN
)/$(2)/$(lastword
$(subst /, ,$(@
)))) || \
247 ( $(call download
,$(1)) && echo
"Please upload this package $(lastword $(subst /, ,$(@))) to our FTP" )
249 ifeq ($(shell which xzcat
>/dev
/null
2>&1 || echo FAIL
),)
252 XZCAT ?
= $(error xz and lzma client not found
!)
255 ifeq ($(shell which bzcat
>/dev
/null
2>&1 || echo FAIL
),)
258 BZCAT ?
= $(error Bunzip2 client
(bzcat
) not found
!)
261 ifeq ($(shell gzcat
--version
>/dev
/null
2>&1 || echo FAIL
),)
263 else ifeq ($(shell zcat
--version
>/dev
/null
2>&1 || echo FAIL
),)
266 ZCAT ?
= $(error Gunzip client
(zcat
) not found
!)
269 ifeq ($(shell sha512sum
--version
>/dev
/null
2>&1 || echo FAIL
),)
270 SHA512SUM
= sha512sum
--check
271 else ifeq ($(shell shasum
--version
>/dev
/null
2>&1 || echo FAIL
),)
272 SHA512SUM
= shasum
-a
512 --check
273 else ifeq ($(shell openssl version
>/dev
/null
2>&1 || echo FAIL
),)
274 SHA512SUM
= openssl dgst
-sha512
276 SHA512SUM
= $(error SHA-512 checksumming not found
!)
279 ifeq ($(shell protoc
--version
>/dev
/null
2>&1 || echo FAIL
),)
282 PROTOC ?
= $(error Protobuf compiler
(protoc
) not found
!)
288 HOSTCONF
:= --prefix="$(PREFIX)"
289 HOSTCONF
+= --datarootdir
="$(PREFIX)/share"
290 HOSTCONF
+= --includedir="$(PREFIX)/include"
291 HOSTCONF
+= --libdir="$(PREFIX)/lib"
292 HOSTCONF
+= --build
="$(BUILD)" --host
="$(HOST)" --target
="$(HOST)"
293 HOSTCONF
+= --program-prefix
=""
295 HOSTCONF
+= --enable-static
--disable-shared
--disable-dependency-tracking
297 HOSTCONF
+= --without-pic
300 HOSTCONF
+= --with-pic
305 CC
="$(CC)" CXX
="$(CXX)" LD
="$(LD)" \
306 AR
="$(AR)" CCAS
="$(CCAS)" RANLIB
="$(RANLIB)" STRIP
="$(STRIP)" \
307 PATH
="$(PREFIX)/bin:$(PATH)"
308 HOSTVARS
:= $(HOSTTOOLS
) \
309 CPPFLAGS
="$(CPPFLAGS)" \
311 CXXFLAGS
="$(CXXFLAGS)" \
313 HOSTVARS_PIC
:= $(HOSTTOOLS
) \
314 CPPFLAGS
="$(CPPFLAGS) $(PIC)" \
315 CFLAGS
="$(CFLAGS) $(PIC)" \
316 CXXFLAGS
="$(CXXFLAGS) $(PIC)" \
320 rm -Rf
$(@
:.
tar.xz
=) && \
321 $(GIT
) clone
$(subst HEAD
, --depth
1,$(findstring HEAD
, $3)) $(2:%=--branch
%) $(1) $(@
:.
tar.xz
=) && \
322 (cd
$(@
:.
tar.xz
=) && $(GIT
) checkout
$(3:%= %)) && \
323 rm -Rf
$(@
:%.
tar.xz
=%)/.git
&& \
325 tar cvJ
$(notdir $(@
:.
tar.xz
=))) > $@
&& \
328 $(foreach f
,$(filter $(TARBALLS
)/%,$^
), \
329 grep
-- " $(f:$(TARBALLS)/%=%)$$" \
330 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS" &&) \
331 (cd
$(TARBALLS
) && $(1) /dev
/stdin
) < \
332 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS"
333 CHECK_SHA512
= $(call checksum
,$(SHA512SUM
),SHA512
)
334 UNPACK
= $(RM
) -R
$@ \
335 $(foreach f
,$(filter %.
tar.gz
%.tgz
,$^
), && tar xvzf
$(f
)) \
336 $(foreach f
,$(filter %.
tar.bz2
,$^
), && tar xvjf
$(f
)) \
337 $(foreach f
,$(filter %.
tar.xz
,$^
), && tar xvJf
$(f
)) \
338 $(foreach f
,$(filter %.zip
,$^
), && unzip
$(f
))
339 UNPACK_DIR
= $(patsubst %.
tar,%,$(basename $(notdir $<)))
340 APPLY
= (cd
$(UNPACK_DIR
) && patch
-fp1
) <
341 pkg_static
= (cd
$(UNPACK_DIR
) && ..
/..
/..
/contrib
/src
/pkg-static.sh
$(1))
342 MOVE
= mv
$(UNPACK_DIR
) $@
&& touch
$@
344 AUTOMAKE_DATA_DIRS
=$(foreach n
,$(foreach n
,$(subst :, ,$(shell echo
$$PATH)),$(abspath
$(n
)/..
/share
)),$(wildcard $(n
)/automake
*))
345 UPDATE_AUTOCONFIG
= for
dir in
$(AUTOMAKE_DATA_DIRS
); do \
346 if
test -f
"$${dir}/config.sub" -a
-f
"$${dir}/config.guess"; then \
347 cp
"$${dir}/config.sub" "$${dir}/config.guess" $(UNPACK_DIR
); \
353 AUTORECONF
= AUTOPOINT
=true autoreconf
355 AUTORECONF
= autoreconf
357 RECONF
= mkdir
-p
-- $(PREFIX
)/share
/aclocal
&& \
358 cd
$< && $(AUTORECONF
) -fiv
$(ACLOCAL_AMFLAGS
)
359 CMAKE
= cmake .
-DCMAKE_TOOLCHAIN_FILE
=$(abspath toolchain.cmake
) \
360 -DCMAKE_INSTALL_PREFIX
=$(PREFIX
) $(CMAKE_GENERATOR
)
363 # Per-package build rules
366 include $(SRC
)/*/rules.mak
368 ifeq ($(PKGS_DISABLE
), all)
374 ifneq ($(filter $(PKGS_DISABLE
),$(PKGS_ENABLE
)),)
375 $(error Same package
(s
) disabled and enabled at the same time
)
377 # Apply automatic selection (= remove distro packages):
378 PKGS_AUTOMATIC
:= $(filter-out $(PKGS_FOUND
),$(PKGS
))
379 # Apply manual selection (from bootstrap):
380 PKGS_MANUAL
:= $(sort $(PKGS_ENABLE
) $(filter-out $(PKGS_DISABLE
),$(PKGS_AUTOMATIC
)))
381 # Resolve dependencies:
382 PKGS_DEPS
:= $(filter-out $(PKGS_FOUND
) $(PKGS_MANUAL
),$(sort $(foreach p
,$(PKGS_MANUAL
),$(DEPS_
$(p
)))))
383 PKGS
:= $(sort $(PKGS_MANUAL
) $(PKGS_DEPS
))
385 fetch
: $(PKGS
:%=.sum-
%)
386 fetch-all
: $(PKGS_ALL
:%=.sum-
%)
387 install: $(PKGS
:%=.
%)
390 -$(RM
) $(foreach p
,$(PKGS_ALL
),.
$(p
) .sum-
$(p
) .dep-
$(p
))
391 -$(RM
) toolchain.cmake
392 -$(RM
) -R
"$(PREFIX)"
393 -$(RM
) -R
"$(BUILDBINDIR)"
397 -$(RM
) $(TARBALLS
)/*.
*
403 PREBUILT_URL
=ftp
://ftp.videolan.org
/pub
/videolan
/contrib
/$(HOST
)/vlc-contrib-
$(HOST
)-latest.
tar.bz2
405 vlc-contrib-
$(HOST
)-latest.
tar.bz2
:
406 $(call download
,$(PREBUILT_URL
))
408 prebuilt
: vlc-contrib-
$(HOST
)-latest.
tar.bz2
410 $(RM
) -r
$(TOPDST
)/$(HOST
)
412 cd
$(TOPDST
)/$(HOST
) && $(SRC
)/change_prefix.sh
414 ifndef HAVE_CROSS_COMPILE
415 $(RM
) `find $(TOPDST)/$(HOST)/bin | file -f- | grep ELF | awk -F: '{print $$1}' | xargs`
423 # remove useless files
424 cd tmp
/$(notdir $(PREFIX
)); \
425 cd share
; rm -Rf man doc gtk-doc
info lua projectM
; cd ..
; \
426 rm -Rf man sbin etc lib
/lua lib
/sidplay
427 cd tmp
/$(notdir $(PREFIX
)) && $(abspath
$(SRC
))/change_prefix.sh
$(PREFIX
) @@CONTRIB_PREFIX@@
428 (cd tmp
&& tar c
$(notdir $(PREFIX
))/) | bzip2
-c
> ..
/vlc-contrib-
$(HOST
)-$(DATE
).
tar.bz2
432 @echo
' $(PKGS_ALL)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
433 @echo Distribution-provided packages
:
434 @echo
' $(PKGS_FOUND)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
435 @echo Automatically selected packages
:
436 @echo
' $(PKGS_AUTOMATIC)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
437 @echo Manually deselected packages
:
438 @echo
' $(PKGS_DISABLE)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
439 @echo Manually selected packages
:
440 @echo
' $(PKGS_ENABLE)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
441 @echo Depended-on packages
:
442 @echo
' $(PKGS_DEPS)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
443 @echo To-be-built packages
:
444 @echo
' $(PKGS)' | tr
" " "\n" |
sort | tr
"\n" " " |fmt
449 .PHONY
: all fetch fetch-all
install mostlyclean clean distclean package list help prebuilt
455 ifdef HAVE_WINDOWSPHONE
456 echo
"set(CMAKE_SYSTEM_NAME WindowsPhone)" >> $@
459 echo
"set(CMAKE_SYSTEM_NAME WindowsStore)" >> $@
461 echo
"set(CMAKE_SYSTEM_NAME Windows)" >> $@
464 echo
"set(CMAKE_RC_COMPILER $(HOST)-windres)" >> $@
467 echo
"set(CMAKE_SYSTEM_NAME Darwin)" >> $@
468 echo
"set(CMAKE_C_FLAGS $(CFLAGS))" >> $@
469 echo
"set(CMAKE_CXX_FLAGS $(CFLAGS) $(EXTRA_CXXFLAGS))" >> $@
470 echo
"set(CMAKE_LD_FLAGS $(LDFLAGS))" >> $@
471 echo
"set(CMAKE_AR ar CACHE FILEPATH "Archiver
")" >> $@
473 echo
"set(CMAKE_OSX_SYSROOT $(IOS_SDK))" >> $@
475 echo
"set(CMAKE_OSX_SYSROOT $(MACOSX_SDK))" >> $@
478 ifdef HAVE_CROSS_COMPILE
479 echo
"set(_CMAKE_TOOLCHAIN_PREFIX $(HOST)-)" >> $@
481 # cmake will overwrite our --sysroot with a native (host) one on Darwin
482 # Set it to "" right away to short-circuit this behaviour
483 echo
"set(CMAKE_CXX_SYSROOT_FLAG \"\")" >> $@
484 echo
"set(CMAKE_C_SYSROOT_FLAG \"\")" >> $@
485 echo
"set(CMAKE_SYSTEM_NAME Android)" >> $@
488 echo
"set(CMAKE_C_COMPILER $(CC))" >> $@
489 echo
"set(CMAKE_CXX_COMPILER $(CXX))" >> $@
490 echo
"set(CMAKE_FIND_ROOT_PATH $(PREFIX))" >> $@
491 echo
"set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $@
492 echo
"set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $@
493 echo
"set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $@
495 # Default pattern rules
496 .sum-
%: $(SRC
)/%/SHA512SUMS
501 $(error Download and
check target not defined for
$*)
503 # Dummy dependency on found packages
504 $(patsubst %,.dep-
%,$(PKGS_FOUND
)): .dep-
%:
507 # Real dependency on missing packages
508 $(patsubst %,.dep-
%,$(filter-out $(PKGS_FOUND
),$(PKGS_ALL
))): .dep-
%: .
%
513 # Dependency propagation (convert 'DEPS_foo = bar' to '.foo: .bar')
514 $(foreach p
,$(PKGS_ALL
),.
$(p
)): .
%: $$(foreach d
,$$(DEPS_
$$*),.dep-
$$(d
))