1 # Cargo/Rust specific makefile rules for VLC 3rd party libraries ("contrib")
2 # Copyright (C) 2003-2020 the VideoLAN team
4 # This file is under the same license as the vlc package.
8 ifeq ($(HOST
),i686-w64-mingw32
)
9 RUST_TARGET
= i686-pc-windows-gnu
# ARCH is i386
10 else ifeq ($(HOST
),x86_64-w64-mingw32
)
11 RUST_TARGET
= $(ARCH
)-pc-windows-gnu
13 # Not supported on armv7/aarch64 yet
16 else ifdef HAVE_ANDROID
19 ifneq ($(ARCH
),arm
) # iOS 32bit is Tier 3
20 ifneq ($(ARCH
),i386
) # iOS 32bit is Tier 3
21 ifndef HAVE_TVOS
# tvOS is Tier 3
22 RUST_TARGET
= $(ARCH
)-apple-ios
26 else ifdef HAVE_MACOSX
27 ifneq ($(ARCH
),aarch64
) # macOS ARM-64 is unsupported
28 RUST_TARGET
= $(ARCH
)-apple-darwin
30 else ifdef HAVE_SOLARIS
31 RUST_TARGET
= x86_64-sun-solaris
33 ifeq ($(HOST
),arm-linux-gnueabihf
)
34 RUST_TARGET
= arm-unknown-linux-gnueabihf
#add eabihf
36 RUST_TARGET
= $(ARCH
)-unknown-linux-gnu
42 # For now, VLC don't support Tier 3 platforms (ios 32bit, tvOS).
43 # Supporting a Tier 3 platform means building an untested rust toolchain.
44 # TODO Let's hope tvOS move from Tier 3 to Tier 2 before the VLC 4.0 release.
45 ifneq ($(RUST_TARGET
),)
49 RUSTUP_HOME
= $(BUILDBINDIR
)/.rustup
50 CARGO_HOME
= $(BUILDBINDIR
)/.cargo
52 CARGO
= .
$(CARGO_HOME
)/env
&& RUSTUP_HOME
=$(RUSTUP_HOME
) CARGO_HOME
=$(CARGO_HOME
) cargo
54 CARGO_INSTALL_ARGS
= --target
=$(RUST_TARGET
) --prefix=$(PREFIX
) \
55 --library-type staticlib
--release
57 # Use the .cargo-vendor source if present, otherwise use crates.io
58 CARGO_INSTALL_ARGS
+= \
59 $(shell test -d
$<-vendor
&& echo
--frozen
--offline || echo
--locked
)
61 CARGO_INSTALL
= $(CARGO
) install $(CARGO_INSTALL_ARGS
)
63 CARGOC_INSTALL
= export TARGET_CC
=$(CC
) && export TARGET_AR
=$(AR
) && \
64 export TARGET_CFLAGS
="$(CFLAGS)" && \
65 export RUSTFLAGS
="-C panic=abort -C opt-level=z" && \
66 $(CARGO
) capi
install $(CARGO_INSTALL_ARGS
)
69 $(call download
,$(CONTRIB_VIDEOLAN
)/$(2)/$(1)) ||
(\
71 echo
"WARNING: cargo vendor archive for $(1) not found" && \
75 # Extract and move the vendor archive if the checksum is valid. Succeed even in
76 # case of error (download or checksum failed). In that case, the cargo-vendor
77 # archive won't be used (crates.io will be used directly).
78 .
%-vendor
: $(SRC
)/%-vendor
/SHA512SUMS
79 $(RM
) -R
$(patsubst .
%,%,$@
)
80 -$(call checksum
,$(SHA512SUM
),SHA512
,.
) \
81 $(foreach f
,$(filter %.
tar.bz2
,$^
), && tar xvjfo
$(f
) && \
82 mv
$(patsubst %.
tar.bz2
,%,$(notdir $(f
))) $(patsubst .
%,%,$@
))
85 CARGO_VENDOR_SETUP
= \
86 if
test -d
$@
-vendor
; then \
87 mkdir
-p
$(UNPACK_DIR
)/.cargo
; \
88 echo
"[source.crates-io]" > $(UNPACK_DIR
)/.cargo
/config.toml
; \
89 echo
"replace-with = \"vendored-sources\"" >> $(UNPACK_DIR
)/.cargo
/config.toml
; \
90 echo
"[source.vendored-sources]" >> $(UNPACK_DIR
)/.cargo
/config.toml
; \
91 echo
"directory = \"../$@-vendor\"" >> $(UNPACK_DIR
)/.cargo
/config.toml
; \
92 echo
"Using cargo vendor archive for $(UNPACK_DIR)"; \