[vlc-devel] [3.0 PATCH v2 11/20] contrib: clean dependency on win32 pthread

Steve Lhomme robux4 at ycbcr.xyz
Thu Apr 2 13:38:09 CEST 2020


and define the macros to force using the static version

(cherry picked from commit f52ef651974696f59261d699241d622e323a32df)
---
 contrib/src/aom/rules.mak        | 11 +++++++++--
 contrib/src/libplacebo/rules.mak |  6 +++++-
 contrib/src/mysofa/rules.mak     | 11 +++++++++--
 contrib/src/openjpeg/rules.mak   | 10 +++++++++-
 contrib/src/protobuf/rules.mak   |  9 ++++++++-
 contrib/src/srt/rules.mak        |  2 ++
 contrib/src/vpx/rules.mak        |  6 ++++++
 7 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/contrib/src/aom/rules.mak b/contrib/src/aom/rules.mak
index ae33807c73a..6990bcdec10 100644
--- a/contrib/src/aom/rules.mak
+++ b/contrib/src/aom/rules.mak
@@ -20,7 +20,7 @@ aom: aom-$(AOM_VERSION).tar.gz .sum-aom
 	mkdir -p $@-$(AOM_VERSION)
 	tar xvzfo "$<" -C $@-$(AOM_VERSION)
 	$(APPLY) $(SRC)/aom/aom-target-cpu.patch
-ifdef HAVE_WINSTORE
+ifdef HAVE_WIN32
 	$(APPLY) $(SRC)/aom/aom-pthreads-win32.patch
 endif
 ifdef HAVE_ANDROID
@@ -32,7 +32,14 @@ ifdef HAVE_ANDROID
 	cp $(ANDROID_NDK)/sources/android/cpufeatures/cpu-features.c $(ANDROID_NDK)/sources/android/cpufeatures/cpu-features.h aom/aom_ports/
 endif
 
+AOM_CFLAGS   := $(CFLAGS)
+AOM_CXXFLAGS := $(CXXFLAGS)
 DEPS_aom =
+ifdef HAVE_WIN32
+DEPS_aom += pthreads $(DEPS_pthreads)
+AOM_CFLAGS   += -DPTW32_STATIC_LIB
+AOM_CXXFLAGS += -DPTW32_STATIC_LIB
+endif
 
 AOM_LDFLAGS := $(LDFLAGS)
 
@@ -89,7 +96,7 @@ endif
 # libaom doesn't allow in-tree builds
 .aom: aom toolchain.cmake
 	cd $< && mkdir -p aom_build
-	cd $</aom_build && LDFLAGS="$(AOM_LDFLAGS)" $(HOSTVARS) $(CMAKE) ../ $(AOM_CONF)
+	cd $</aom_build && $(HOSTVARS) LDFLAGS="$(AOM_LDFLAGS)" CFLAGS="$(AOM_CFLAGS)" CXXFLAGS="$(AOM_CXXFLAGS)" $(CMAKE) ../ $(AOM_CONF)
 	cd $</aom_build && $(MAKE)
 	cd $</aom_build && ../../../../contrib/src/pkg-static.sh aom.pc
 	cd $</aom_build && $(MAKE) install
diff --git a/contrib/src/libplacebo/rules.mak b/contrib/src/libplacebo/rules.mak
index b9871a00563..b2bfa3ca01a 100644
--- a/contrib/src/libplacebo/rules.mak
+++ b/contrib/src/libplacebo/rules.mak
@@ -4,9 +4,13 @@ PLACEBO_VERSION := 0.2.1
 PLACEBO_URL := https://github.com/haasn/libplacebo/archive/v$(PLACEBO_VERSION).tar.gz
 PLACEBO_ARCHIVE = libplacebo-$(PLACEBO_VERSION).tar.gz
 
+LIBPLACEBO_CFLAGS   := $(CFLAGS)
+LIBPLACEBO_CXXFLAGS := $(CXXFLAGS)
 ifdef HAVE_WIN32
 LIBPLACEBO_WIN32 = HAVE_WIN32=1
 DEPS_libplacebo += pthreads $(DEPS_pthreads)
+LIBPLACEBO_CFLAGS   += -DPTW32_STATIC_LIB
+LIBPLACEBO_CXXFLAGS += -DPTW32_STATIC_LIB
 endif
 
 PKGS += libplacebo
@@ -33,5 +37,5 @@ libplacebo: $(PLACEBO_ARCHIVE) .sum-libplacebo
 # we don't want to depend on meson/ninja for VLC 3.0
 #cd $< && $(HOSTVARS) meson $(PLACEBOCONF) build
 #cd $< && cd build && ninja install
-	cd $< && $(HOSTVARS_PIC) PREFIX=$(PREFIX) $(LIBPLACEBO_WIN32) make install
+	cd $< && $(HOSTVARS_PIC) PREFIX=$(PREFIX) $(LIBPLACEBO_WIN32) CFLAGS="$(LIBPLACEBO_CFLAGS)" CXXFLAGS="$(LIBPLACEBO_CXXFLAGS)" make install
 	touch $@
diff --git a/contrib/src/mysofa/rules.mak b/contrib/src/mysofa/rules.mak
index fcaab5098ad..0a0377ecc17 100644
--- a/contrib/src/mysofa/rules.mak
+++ b/contrib/src/mysofa/rules.mak
@@ -9,7 +9,14 @@ ifeq ($(call need_pkg,"libmysofa"),)
 PKGS_FOUND += mysofa
 endif
 
-DEPS_mysofa += pthreads zlib $(DEPS_pthreads) $(DEPS_zlib)
+MYSOFA_CFLAGS   := $(CFLAGS)
+MYSOFA_CXXFLAGS := $(CXXFLAGS)
+DEPS_mysofa += zlib $(DEPS_zlib)
+ifdef HAVE_WIN32
+DEPS_mysofa += pthreads $(DEPS_pthreads)
+MYSOFA_CFLAGS   += -DPTW32_STATIC_LIB
+MYSOFA_CXXFLAGS += -DPTW32_STATIC_LIB
+endif
 
 $(TARBALLS)/libmysofa-$(MYSOFA_VERSION).tar.gz:
 	$(call download_pkg,$(MYSOFA_URL),mysofa)
@@ -22,7 +29,7 @@ mysofa: libmysofa-$(MYSOFA_VERSION).tar.gz .sum-mysofa
 
 .mysofa: mysofa toolchain.cmake
 	-cd $< && rm CMakeCache.txt
-	cd $< && $(HOSTVARS) $(CMAKE) -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
+	cd $< && $(HOSTVARS) CFLAGS="$(MYSOFA_CFLAGS)" CXXFLAGS="$(MYSOFA_CXXFLAGS)" $(CMAKE) -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=OFF
 	cd $< && $(MAKE) install
 	touch $@
 
diff --git a/contrib/src/openjpeg/rules.mak b/contrib/src/openjpeg/rules.mak
index e41056c10d7..005bf24bfae 100644
--- a/contrib/src/openjpeg/rules.mak
+++ b/contrib/src/openjpeg/rules.mak
@@ -3,6 +3,14 @@
 OPENJPEG_VERSION := 2.3.0
 OPENJPEG_URL := https://github.com/uclouvain/openjpeg/archive/v$(OPENJPEG_VERSION).tar.gz
 
+OPENJPEG_CFLAGS   := $(CFLAGS)
+OPENJPEG_CXXFLAGS := $(CXXFLAGS)
+ifdef HAVE_WIN32
+DEPS_openjpeg += pthreads $(DEPS_pthreads)
+OPENJPEG_CFLAGS   += -DPTW32_STATIC_LIB
+OPENJPEG_CXXFLAGS += -DPTW32_STATIC_LIB
+endif
+
 $(TARBALLS)/openjpeg-v$(OPENJPEG_VERSION).tar.gz:
 	$(call download_pkg,$(OPENJPEG_URL),openjpeg)
 
@@ -22,7 +30,7 @@ endif
 	$(MOVE)
 
 .openjpeg: openjpeg toolchain.cmake
-	cd $< && $(HOSTVARS) $(CMAKE) \
+	cd $< && $(HOSTVARS) CFLAGS="$(OPENJPEG_CFLAGS)" CXXFLAGS="$(OPENJPEG_CXXFLAGS)" $(CMAKE) \
 		-DBUILD_SHARED_LIBS:bool=OFF -DBUILD_PKGCONFIG_FILES=ON \
 			-DBUILD_CODEC:bool=OFF \
 		.
diff --git a/contrib/src/protobuf/rules.mak b/contrib/src/protobuf/rules.mak
index 87c1b73af7e..2a9a0f3c78e 100644
--- a/contrib/src/protobuf/rules.mak
+++ b/contrib/src/protobuf/rules.mak
@@ -12,7 +12,14 @@ $(TARBALLS)/protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz:
 
 .sum-protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz
 
+PROTOBUF_CFLAGS   := $(CFLAGS)
+PROTOBUF_CXXFLAGS := $(CXXFLAGS)
 DEPS_protobuf = zlib $(DEPS_zlib)
+ifdef HAVE_WIN32
+DEPS_protobuf += pthreads $(DEPS_pthreads)
+PROTOBUF_CFLAGS   += -DPTW32_STATIC_LIB
+PROTOBUF_CXXFLAGS += -DPTW32_STATIC_LIB
+endif
 
 protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
 	$(UNPACK)
@@ -22,6 +29,6 @@ protobuf: protobuf-$(PROTOBUF_VERSION)-cpp.tar.gz .sum-protobuf
 
 .protobuf: protobuf
 	$(RECONF)
-	cd $< && $(HOSTVARS) ./configure $(HOSTCONF) --with-protoc="$(PROTOC)"
+	cd $< && CFLAGS="$(PROTOBUF_CFLAGS)" CXXFLAGS="$(PROTOBUF_CXXFLAGS)" $(HOSTVARS) ./configure $(HOSTCONF) --with-protoc="$(PROTOC)"
 	cd $< && $(MAKE) && $(MAKE) install
 	touch $@
diff --git a/contrib/src/srt/rules.mak b/contrib/src/srt/rules.mak
index 0f0e4bf3627..bef15200f24 100644
--- a/contrib/src/srt/rules.mak
+++ b/contrib/src/srt/rules.mak
@@ -13,6 +13,8 @@ endif
 
 ifdef HAVE_WIN32
 DEPS_srt += pthreads $(DEPS_pthreads)
+SRT_CFLAGS   += -DPTW32_STATIC_LIB
+SRT_CXXFLAGS += -DPTW32_STATIC_LIB
 endif
 
 $(TARBALLS)/srt-$(SRT_VERSION).tar.gz:
diff --git a/contrib/src/vpx/rules.mak b/contrib/src/vpx/rules.mak
index 7e899d898e2..e002be69074 100644
--- a/contrib/src/vpx/rules.mak
+++ b/contrib/src/vpx/rules.mak
@@ -25,6 +25,8 @@ endif
 
 DEPS_vpx =
 
+VPX_CFLAGS   := $(CFLAGS)
+VPX_CXXFLAGS := $(CXXFLAGS)
 ifdef HAVE_WIN32
 DEPS_vpx += pthreads $(DEPS_pthreads)
 endif
@@ -169,6 +171,10 @@ VPX_HOSTVARS = $(HOSTVARS)
 endif
 endif
 
+ifdef HAVE_WIN32
+VPX_HOSTVARS += CFLAGS="$(CFLAGS) -DPTW32_STATIC_LIB" CXXFLAGS="$(CXXFLAGS) -DPTW32_STATIC_LIB"
+endif
+
 .vpx: libvpx
 	rm -rf $(PREFIX)/include/vpx
 	cd $< && LDFLAGS="$(VPX_LDFLAGS)" CROSS=$(VPX_CROSS) $(VPX_HOSTVARS) ./configure --target=$(VPX_TARGET) \
-- 
2.17.1



More information about the vlc-devel mailing list