summaryrefslogtreecommitdiff
path: root/mingw
diff options
context:
space:
mode:
authorclaude-bot <[email protected]>2026-07-13 12:40:01 +0000
committerclaude-bot <[email protected]>2026-07-13 12:40:01 +0000
commit02fe7437413eaaf7cee46e5a1862c1fc7ac0dbba (patch)
tree50a2f61b89ee66f9ff58b7b9167a8e5232e19e3c /mingw
downloadopusfile-master.tar.gz
opusfile-master.zip
Import xiph/opusfile @ 4174c26e0aaab19d01afdea0a46f7f95fdc6b3e6HEADmaster
Snapshot for re3/reVC vendoring, per @lzcnt. Source: https://github.com/xiph/opusfile (4174c26e0aaab19d01afdea0a46f7f95fdc6b3e6).
Diffstat (limited to 'mingw')
-rw-r--r--mingw/Dockerfile21
-rw-r--r--mingw/Makefile113
-rw-r--r--mingw/README.md69
3 files changed, 203 insertions, 0 deletions
diff --git a/mingw/Dockerfile b/mingw/Dockerfile
new file mode 100644
index 0000000..f394e90
--- /dev/null
+++ b/mingw/Dockerfile
@@ -0,0 +1,21 @@
+FROM fedora:32
+MAINTAINER [email protected]
+
+# Linux build.
+RUN dnf update -y --setopt=deltarpm=0
+RUN dnf install -y git gcc make wget xz
+RUN dnf install -y autoconf automake libtool pkgconfig
+
+# mingw cross build.
+RUN dnf install -y mingw32-gcc zip
+
+RUN dnf clean all
+
+RUN git clone https://gitlab.xiph.org/xiph/opusfile.git
+
+WORKDIR opusfile
+RUN git pull
+COPY Makefile mingw/Makefile
+RUN make -C mingw
+RUN ./autogen.sh && ./configure --host=i686-w64-mingw32 --prefix=${PWD}/mingw PKG_CONFIG_PATH=${PWD}/mingw/lib/pkgconfig && make && make check && make install
+RUN make -C mingw package
diff --git a/mingw/Makefile b/mingw/Makefile
new file mode 100644
index 0000000..ab28449
--- /dev/null
+++ b/mingw/Makefile
@@ -0,0 +1,113 @@
+# Cross-compile opusfile under mingw
+
+TOOL_PREFIX ?= i686-w64-mingw32
+
+# To build opusfile under mingw, we first need to build:
+DEPS = ogg opus ssl
+
+ogg_URL := https://downloads.xiph.org/releases/ogg/libogg-1.3.4.tar.xz
+ogg_SHA := c163bc12bc300c401b6aa35907ac682671ea376f13ae0969a220f7ddf71893fe
+
+opus_URL := https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz
+opus_SHA := 65b58e1e25b2a114157014736a3d9dfeaad8d41be1c8179866f144a2fb44ff9d
+
+ssl_URL := https://openssl.org/source/openssl-1.0.2u.tar.gz
+ssl_SHA := ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
+
+all: $(DEPS)
+
+libopusfile-0.dll: ../unix/Makefile $(DEPS)
+ CC=$(TOOL_PREFIX)-gcc \
+ RANLIB=$(TOOL_PREFIX)-ranlib \
+ PKG_CONFIG_PATH=$(CURDIR)/lib/pkgconfig \
+ $(MAKE) -f $<
+
+opusfile: $(DEPS)
+ $(MKDIR) $@
+ cd $@ && ../configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR) \
+ PKG_CONFIG_PATH=$(CURDIR)/lib/pkgconfig
+ $(MAKE) -C $@
+
+clean:
+ $(RM) -r objs
+ $(RM) -r bin include lib share ssl
+ $(RM) -r $(DEP_DIRS)
+ $(RM) opusfile_example.exe seeking_example.exe
+ $(RM) libopusfile.a libopusurl.a
+
+# Generate rules to download and verify each dependency.
+define WGET_template =
+ # Generate tarball name from the url.
+ DEP_TARBALLS += $$(notdir $$($(1)_URL))
+ $(1)_DIR := $$(basename $$(basename $$(notdir $$($(1)_URL))))
+ DEP_DIRS += $$($(1)_DIR)
+
+ # Verify and unpack tarball.
+ $$($(1)_DIR): $$(notdir $$($(1)_URL))
+ @if test "$$($(1)_SHA)" = "$$$$(sha256sum $$< | cut -f 1 -d ' ')"; \
+ then \
+ echo "+ $$< checksum verified."; \
+ else \
+ echo "! $$< checksum didn't match!"; \
+ $(RM) $$<; exit 1; \
+ fi
+ tar xf $$<
+
+ # Fetch tarball from the url.
+ $$(notdir $$($(1)_URL)):
+ wget $$($(1)_URL)
+
+ # Hook project-specific build rule.
+ $(1): $(1)_BUILD
+endef
+$(foreach dep,$(DEPS),$(eval $(call WGET_template,$(dep))))
+
+fetch: $(DEP_TARBALLS)
+
+realclean: clean
+ $(RM) $(DEP_TARBALLS)
+
+# Build scripts for each specific target.
+
+# NOTE: 'make check' generally requires wine with cross-compiling.
+ogg_BUILD: $(ogg_DIR)
+ cd $< && ./configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR)
+ $(MAKE) -C $< install
+
+opus_BUILD: $(opus_DIR)
+ cd $< && ./configure --host=$(TOOL_PREFIX) --prefix=$(CURDIR)
+ $(MAKE) -C $< install
+
+ssl_BUILD: $(ssl_DIR)
+ cd $< && ./Configure mingw \
+ --prefix=$(CURDIR) \
+ --cross-compile-prefix=$(TOOL_PREFIX)-
+ $(MAKE) -C $< depend
+ $(MAKE) -C $<
+ $(MAKE) -C $< install
+
+# Package the binaries.
+DIST_VERSION := $(shell git describe --dirty)
+DIST := opusfile-$(DIST_VERSION)-win32
+package: $(DIST).zip
+
+$(DIST).zip: $(DIST)
+ zip -r $@ $</*
+ @echo $@ ready to go.
+
+$(DIST): $(addprefix $(CURDIR)/bin/, libogg-0.dll libopus-0.dll)
+ #cd .. && make install
+ mkdir -p $(DIST)
+ cp ../AUTHORS ../COPYING ../README.md ../include/opusfile.h $@
+ cp .libs/libopusfile-0.dll $@
+ cp .libs/libopusfile.a $@
+ cp .libs/libopusurl-0.dll $@
+ cp .libs/libopusurl.a $@
+ cp bin/*.dll $@
+ cp *.exe $@
+ cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_dw2-1.dll $@
+ cp /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll $@
+ i686-w64-mingw32-strip $@/*.exe
+ i686-w64-mingw32-strip $@/*.dll
+ i686-w64-mingw32-strip $@/*.a
+ cd $@ && sha256sum * > SHA256SUMS.txt
diff --git a/mingw/README.md b/mingw/README.md
new file mode 100644
index 0000000..9134149
--- /dev/null
+++ b/mingw/README.md
@@ -0,0 +1,69 @@
+# Cross-compiling under mingw
+
+Just running `make libopusfile-0.dll` in this directory should download
+and build opusfile and its dependencies. Some mingw
+libraries need to be compiled into the final package.
+
+## Generic instructions
+
+To build opusfile under mingw, you need to first build:
+
+- libogg
+- libopus
+- openssl
+
+For 'make check' to work, you may need wine installed.
+
+To build openssl, try:
+
+ CROSS_COMPILE="i686-w64-mingw32-" ./Configure mingw no-asm no-shared --prefix=$PWD/mingw && make depend && make -j8 && make install
+
+To build opusfile, try:
+
+ CC=i686-w64-mingw32-gcc PKG_CONFIG_PATH=$PWD/lib/pkgconfig RANLIB=i686-w64-mingw32-ranlib make -f ../unix/Makefile
+
+## Building the release package
+
+Running `make package` should produce a binary package.
+
+The steps are something like
+
+- Compile dynamic opusfile with:
+ - ./configure --host=i686-w64-mingw32 --prefix=/path/to/builddir/mingw \
+ PKG_CONFIG_PATH=/path/to/builddir/mingw/lib/pkgconfig
+ - make && make check && make -C doc/latex
+ - If Doxygen fails because of unescaped '#' characters in URLs
+ Update to at least Doxygen 1.8.15. Doxygen 1.8.3 also works.
+- mkdir opusfile-${version}-win32
+- Copy AUTHORS COPYING README.md include/opusfile.h to the release dir.
+ - Don't put opusfile.h in an opusfile-${version}-win32/include directory,
+ just put it straight in the release dir.
+- Merge changes between README.md and the version in the last
+ binary release. E.g. it's good to include versions of the dependencies,
+ release notes, etc.
+- Convert README.md to DOS line endings.
+- Copy .libs/libopusfile-0.dll to the release dir.
+- Copy .libs/libopusfile.a to the release dir.
+- Copy .libs/libopusurl-0.dll to the release dir.
+- Copy .libs/libopusurl.a to the release dir.
+- Copy mingw/bin/*.dll to the release dir for dependencies.
+- Copy any other dependent dlls, e.g. on Fedora 32 I needed to copy
+ /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_dw2-1.dll
+ /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll
+ On Fedora 23 I needed to copy
+ /usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll
+ /usr/i686-w64-mingw32/sys-root/mingw/bin/libwinpthread-1.dll
+ On Gentoo I needed to copy
+ /usr/lib64/gcc/i686-w64-mingw32/7.3.0/libgcc_s_sjlj-1.dll
+ TODO: It may be possible to avoid this with CFLAGS="-static-libgcc"
+- Copy doc/latex/refman.pdf to opusfile-${version}-win32/opusfile-${version}.pdf
+- Copy examples/.libs/*.exe to the release dir.
+- Run "i686-w64-ming32-strip *.dll *.a *.exe" in the release dir.
+- In the release dir, run:
+ sha256sum * > SHA256SUMS.txt
+ gpg --detach-sign --armor SHA256SUMS.txt
+- In the parent directory, create the archive:
+ zip -r opusfile-${version}-win32.zip opusfile-${version}-win32/*
+- Copy the archive to a clean system and verify the examples work
+ to make sure you've included all the necessary libraries.
+