summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contrib/bzip2/module.defs1
-rw-r--r--contrib/faad2/P00-mingw-types.patch25
-rw-r--r--contrib/ffmpeg/module.defs24
-rw-r--r--contrib/libdvdread/P02-mingw-ssize_t.patch26
-rw-r--r--contrib/libdvdread/P03-mingw-disable-dlopen.patch134
-rw-r--r--contrib/libdvdread/P04-mingw-endian-macros.patch29
-rw-r--r--contrib/libdvdread/P05-mingw-large-file.patch28
-rw-r--r--contrib/libmkv/P00-mingw-large-file.patch24
-rw-r--r--contrib/libmp4v2/P00-mingw-static.patch16
-rw-r--r--contrib/libmp4v2/P01-mingw-msvcrt-lower.patch31
-rw-r--r--contrib/libmp4v2/P02-mingw-configure.patch26
-rw-r--r--contrib/libmp4v2/module.defs12
-rw-r--r--contrib/pthreadw32/module.defs25
-rw-r--r--contrib/pthreadw32/module.rules2
-rw-r--r--contrib/x264/module.defs12
-rw-r--r--contrib/xvidcore/A00-nasm.patch13
-rw-r--r--contrib/xvidcore/A01-fdct.patch8
-rw-r--r--contrib/xvidcore/P00-darwin.patch56
-rw-r--r--contrib/xvidcore/P01-cygwin.patch25
-rw-r--r--contrib/xvidcore/module.defs10
-rw-r--r--contrib/zlib/module.defs6
-rw-r--r--libhb/common.h14
-rw-r--r--libhb/decavcodec.c4
-rw-r--r--libhb/decmetadata.c2
-rw-r--r--libhb/fifo.c2
-rw-r--r--libhb/module.defs33
-rw-r--r--libhb/module.rules12
-rw-r--r--libhb/ports.c29
-rw-r--r--libhb/ports.h3
-rw-r--r--libhb/reader.c2
-rw-r--r--make/configure.py77
-rw-r--r--make/include/contrib.defs6
-rw-r--r--make/include/gcc.defs60
-rw-r--r--make/include/main.defs35
-rw-r--r--make/include/main.rules4
-rw-r--r--make/variant/mingw.defs10
-rw-r--r--test/module.defs5
-rw-r--r--test/test.c12
38 files changed, 683 insertions, 160 deletions
diff --git a/contrib/bzip2/module.defs b/contrib/bzip2/module.defs
index 7c9c5528b..76eacbe90 100644
--- a/contrib/bzip2/module.defs
+++ b/contrib/bzip2/module.defs
@@ -8,6 +8,7 @@ BZIP2.CONFIGURE = $(TOUCH.exe) $@
BZIP2.BUILD.extra = \
CC=$(BZIP2.GCC.gcc) \
CFLAGS="$(call fn.ARGS,BZIP2.GCC,*archs)" \
+ RANLIB="$(RANLIB.exe)"
PREFIX=$(call fn.ABSOLUTE,$(CONTRIB.build/))
BZIP2.BUILD.ntargets = libbz2.a
diff --git a/contrib/faad2/P00-mingw-types.patch b/contrib/faad2/P00-mingw-types.patch
new file mode 100644
index 000000000..3e5bba531
--- /dev/null
+++ b/contrib/faad2/P00-mingw-types.patch
@@ -0,0 +1,25 @@
+diff -Naur faad2.orig/common/mp4ff/mp4ff_int_types.h faad2/common/mp4ff/mp4ff_int_types.h
+--- faad2.orig/common/mp4ff/mp4ff_int_types.h 2005-02-01 08:15:55.000000000 -0500
++++ faad2/common/mp4ff/mp4ff_int_types.h 2008-10-07 16:43:06.000000000 -0400
+@@ -1,7 +1,7 @@
+ #ifndef _MP4FF_INT_TYPES_H_
+ #define _MP4FF_INT_TYPES_H_
+
+-#if defined (_WIN32)
++#if defined(_WIN32) && !defined(__MINGW32__)
+
+ typedef char int8_t;
+ typedef unsigned char uint8_t;
+diff -Naur faad2.orig/frontend/main.c faad2/frontend/main.c
+--- faad2.orig/frontend/main.c 2007-11-01 08:33:29.000000000 -0400
++++ faad2/frontend/main.c 2008-10-07 16:55:49.000000000 -0400
+@@ -31,7 +31,9 @@
+ #ifdef _WIN32
+ #define WIN32_LEAN_AND_MEAN
+ #include <windows.h>
++#ifndef __MINGW32__
+ #define off_t __int64
++#endif
+ #else
+ #include <time.h>
+ #endif
diff --git a/contrib/ffmpeg/module.defs b/contrib/ffmpeg/module.defs
index 63ae39f44..af34b3a92 100644
--- a/contrib/ffmpeg/module.defs
+++ b/contrib/ffmpeg/module.defs
@@ -7,6 +7,8 @@ FFMPEG.EXTRACT.tarbase = ffmpeg-0.5
FFMPEG.CONFIGURE.deps =
FFMPEG.CONFIGURE.env =
FFMPEG.CONFIGURE.host =
+#FFMPEG.CONFIGURE.shared =
+#FFMPEG.CONFIGURE.static =
FFMPEG.CONFIGURE.extra = \
--disable-bsfs \
@@ -21,19 +23,27 @@ FFMPEG.CONFIGURE.extra = \
--enable-gpl \
--enable-libfaad \
--enable-muxer=ipod \
- --enable-pthreads \
--enable-swscale \
--cc="$(GCC.gcc)" \
--extra-cflags="$(call fn.ARGS,FFMPEG.GCC,*archs ?extra) -I$(call fn.ABSOLUTE,$(CONTRIB.build/)include)" \
--extra-ldflags="$(call fn.ARGS,FFMPEG.GCC,*archs ?extra) -L$(call fn.ABSOLUTE,$(CONTRIB.build/)lib)"
-ifeq ($(BUILD.cross),1)
- FFMPEG.CONFIGURE.extra += --enable-cross-compile --arch=$(BUILD.machine)
-endif
-
-ifeq (cygwin,$(BUILD.system))
- FFMPEG.CONFIGURE.extra += --enable-memalign-hack
+## check against tuple: B-SYSTEM where B is { 0 | 1 } for cross-compiling flag
+ifeq (0-cygwin,$(BUILD.cross)-$(BUILD.system))
+ FFMPEG.CONFIGURE.extra += --enable-pthreads --enable-memalign-hack
FFMPEG.GCC.args.extra = -fno-common
+else ifeq (1-darwin,$(BUILD.cross)-$(BUILD.system))
+ ## section for darwin-archs
+ FFMPEG.CONFIGURE.extra += --enable-pthreads --enable-cross-compile --arch=$(BUILD.machine)
+else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+ FFMPEG.CONFIGURE.extra += \
+ --enable-w32threads \
+ --enable-memalign-hack \
+ --target-os=mingw32 \
+ --enable-cross-compile --cross-prefix=$(BUILD.cross.prefix)
+ FFMPEG.GCC.args.extra += -fno-common
+else
+ FFMPEG.CONFIGURE.extra += --enable-pthreads
endif
#
diff --git a/contrib/libdvdread/P02-mingw-ssize_t.patch b/contrib/libdvdread/P02-mingw-ssize_t.patch
new file mode 100644
index 000000000..a4dc5eda7
--- /dev/null
+++ b/contrib/libdvdread/P02-mingw-ssize_t.patch
@@ -0,0 +1,26 @@
+diff -Naur libdvdread.orig/configure libdvdread/configure
+--- libdvdread.orig/configure 2006-10-06 04:14:24.000000000 -0400
++++ libdvdread/configure 2009-03-10 17:45:06.000000000 -0400
+@@ -3550,9 +3550,6 @@
+ _ACEOF
+
+ ;;
+- x*mingw32* | x*cygwin*)
+- CFLAGS="${CFLAGS} -Dssize_t=long"
+- ;;
+ x*)
+ ;;
+ esac
+diff -Naur libdvdread.orig/configure.in libdvdread/configure.in
+--- libdvdread.orig/configure.in 2006-10-06 04:12:31.000000000 -0400
++++ libdvdread/configure.in 2009-03-10 17:45:06.000000000 -0400
+@@ -15,9 +15,6 @@
+ CFLAGS="${CFLAGS} -no-cpp-precomp"
+ AC_DEFINE(__DARWIN__, 1, Have a Mac OS X system)
+ ;;
+- x*mingw32* | x*cygwin*)
+- CFLAGS="${CFLAGS} -Dssize_t=long"
+- ;;
+ x*)
+ ;;
+ esac
diff --git a/contrib/libdvdread/P03-mingw-disable-dlopen.patch b/contrib/libdvdread/P03-mingw-disable-dlopen.patch
new file mode 100644
index 000000000..515526289
--- /dev/null
+++ b/contrib/libdvdread/P03-mingw-disable-dlopen.patch
@@ -0,0 +1,134 @@
+diff -Naur libdvdread.orig/configure libdvdread/configure
+--- libdvdread.orig/configure 2006-10-06 04:14:24.000000000 -0400
++++ libdvdread/configure 2009-03-10 17:48:56.000000000 -0400
+@@ -18889,11 +18889,6 @@
+ echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+ if test $ac_cv_lib_dl_dlopen = yes; then
+ DL_LIBS=-ldl
+-else
+- { { echo "$as_me:$LINENO: error: You need libdl (dlopen)" >&5
+-echo "$as_me: error: You need libdl (dlopen)" >&2;}
+- { (exit 1); exit 1; }; }
+-
+ fi
+
+
+diff -Naur libdvdread.orig/dvdread/dvd_input.c libdvdread/dvdread/dvd_input.c
+--- libdvdread.orig/dvdread/dvd_input.c 2005-09-19 09:43:08.000000000 -0400
++++ libdvdread/dvdread/dvd_input.c 2009-03-10 18:01:43.000000000 -0400
+@@ -44,18 +44,6 @@
+
+ char * (*dvdinput_error) (dvd_input_t);
+
+-#ifdef HAVE_DVDCSS_DVDCSS_H
+-/* linking to libdvdcss */
+-#include <dvdcss/dvdcss.h>
+-#define DVDcss_open(a) dvdcss_open((char*)(a))
+-#define DVDcss_close dvdcss_close
+-#define DVDcss_seek dvdcss_seek
+-#define DVDcss_title dvdcss_title
+-#define DVDcss_read dvdcss_read
+-#define DVDcss_error dvdcss_error
+-#else
+-/* dlopening libdvdcss */
+-#include <dlfcn.h>
+ typedef struct dvdcss_s *dvdcss_handle;
+ static dvdcss_handle (*DVDcss_open) (const char *);
+ static int (*DVDcss_close) (dvdcss_handle);
+@@ -63,7 +51,6 @@
+ static int (*DVDcss_title) (dvdcss_handle, int);
+ static int (*DVDcss_read) (dvdcss_handle, void *, int, int);
+ static char * (*DVDcss_error) (dvdcss_handle);
+-#endif
+
+ /* The DVDinput handle, add stuff here for new input methods. */
+ struct dvd_input_s {
+@@ -290,17 +277,7 @@
+ */
+ void dvdinput_free(void)
+ {
+-#ifdef HAVE_DVDCSS_DVDCSS_H
+- /* linked statically, nothing to free */
+ return;
+-#else
+- if(dvdcss_library) {
+- dlclose(dvdcss_library);
+- dvdcss_library = NULL;
+- }
+- dvdcss_library_init = 0;
+- return;
+-#endif
+ }
+
+
+@@ -324,58 +301,6 @@
+
+ verbose = get_verbose();
+
+-#ifdef HAVE_DVDCSS_DVDCSS_H
+- /* linking to libdvdcss */
+- dvdcss_library = &dvdcss_library; /* Give it some value != NULL */
+- /* the DVDcss_* functions have been #defined at the top */
+- dvdcss_version = &dvdcss_interface_2;
+-
+-#else
+-
+- dvdcss_library = dlopen("libdvdcss.so.2", RTLD_LAZY);
+-
+- if(dvdcss_library != NULL) {
+-#if defined(__OpenBSD__) && !defined(__ELF__)
+-#define U_S "_"
+-#else
+-#define U_S
+-#endif
+- DVDcss_open = (dvdcss_handle (*)(const char*))
+- dlsym(dvdcss_library, U_S "dvdcss_open");
+- DVDcss_close = (int (*)(dvdcss_handle))
+- dlsym(dvdcss_library, U_S "dvdcss_close");
+- DVDcss_title = (int (*)(dvdcss_handle, int))
+- dlsym(dvdcss_library, U_S "dvdcss_title");
+- DVDcss_seek = (int (*)(dvdcss_handle, int, int))
+- dlsym(dvdcss_library, U_S "dvdcss_seek");
+- DVDcss_read = (int (*)(dvdcss_handle, void*, int, int))
+- dlsym(dvdcss_library, U_S "dvdcss_read");
+- DVDcss_error = (char* (*)(dvdcss_handle))
+- dlsym(dvdcss_library, U_S "dvdcss_error");
+-
+- dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2");
+-
+- if(dlsym(dvdcss_library, U_S "dvdcss_crack")) {
+- if(verbose >= 0) {
+- fprintf(stderr,
+- "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n"
+- "libdvdread: You should get the latest version from "
+- "http://www.videolan.org/\n" );
+- }
+- dlclose(dvdcss_library);
+- dvdcss_library = NULL;
+- } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek
+- || !DVDcss_read || !DVDcss_error || !dvdcss_version) {
+- if(verbose >= 0) {
+- fprintf(stderr, "libdvdread: Missing symbols in libdvdcss.so.2, "
+- "this shouldn't happen !\n");
+- }
+- dlclose(dvdcss_library);
+- dvdcss_library = NULL;
+- }
+- }
+-#endif /* HAVE_DVDCSS_DVDCSS_H */
+-
+ dvdcss_library_init = 1;
+
+ if(dvdcss_library) {
+diff -Naur libdvdread.orig/dvdread/dvd_reader.c libdvdread/dvdread/dvd_reader.c
+--- libdvdread.orig/dvdread/dvd_reader.c 2006-10-06 03:58:03.000000000 -0400
++++ libdvdread/dvdread/dvd_reader.c 2009-03-10 17:51:22.000000000 -0400
+@@ -183,7 +183,7 @@
+ dev->align = align;
+ }
+
+-#ifdef WIN32 /* replacement gettimeofday implementation */
++#if defined(WIN32) && !defined(__MINGW32__) /* replacement gettimeofday implementation */
+ #include <sys/timeb.h>
+ static int gettimeofday( struct timeval *tv, void *tz )
+ {
diff --git a/contrib/libdvdread/P04-mingw-endian-macros.patch b/contrib/libdvdread/P04-mingw-endian-macros.patch
new file mode 100644
index 000000000..872b8518d
--- /dev/null
+++ b/contrib/libdvdread/P04-mingw-endian-macros.patch
@@ -0,0 +1,29 @@
+diff -Naur libdvdread.orig/dvdread/bswap.h libdvdread/dvdread/bswap.h
+--- libdvdread.orig/dvdread/bswap.h 2006-06-06 16:03:37.000000000 -0400
++++ libdvdread/dvdread/bswap.h 2009-03-13 21:05:23.000000000 -0400
+@@ -83,6 +83,25 @@
+ #define B2N_32(x) x = OSSwapBigToHostConstInt32(x)
+ #define B2N_64(x) x = OSSwapBigToHostConstInt64(x)
+
++#elif defined(__MINGW32__)
++#define B2N_16(x) \
++ x = ((((x) & 0xff00) >> 8) | \
++ (((x) & 0x00ff) << 8))
++#define B2N_32(x) \
++ x = ((((x) & 0xff000000) >> 24) | \
++ (((x) & 0x00ff0000) >> 8) | \
++ (((x) & 0x0000ff00) << 8) | \
++ (((x) & 0x000000ff) << 24))
++#define B2N_64(x) \
++ x = ((((x) & 0xff00000000000000ULL) >> 56) | \
++ (((x) & 0x00ff000000000000ULL) >> 40) | \
++ (((x) & 0x0000ff0000000000ULL) >> 24) | \
++ (((x) & 0x000000ff00000000ULL) >> 8) | \
++ (((x) & 0x00000000ff000000ULL) << 8) | \
++ (((x) & 0x0000000000ff0000ULL) << 24) | \
++ (((x) & 0x000000000000ff00ULL) << 40) | \
++ (((x) & 0x00000000000000ffULL) << 56))
++
+ #else
+ #if defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__) || defined(__INTERIX)
+ /* These systems don't have swap macros */
diff --git a/contrib/libdvdread/P05-mingw-large-file.patch b/contrib/libdvdread/P05-mingw-large-file.patch
new file mode 100644
index 000000000..7ed9b6540
--- /dev/null
+++ b/contrib/libdvdread/P05-mingw-large-file.patch
@@ -0,0 +1,28 @@
+--- libdvdread.orig/dvdread/dvd_input.h 2005-09-06 12:23:00.000000000 -0700
++++ libdvdread/dvdread/dvd_input.h 2009-03-25 15:01:39.000000000 -0700
+@@ -28,6 +28,24 @@
+
+ #define DVDINPUT_READ_DECRYPT (1 << 0)
+
++#if defined( __MINGW32__ )
++# undef lseek
++# define lseek _lseeki64
++# undef fseeko
++# define fseeko fseeko64
++# undef ftello
++# define ftello ftello64
++# define flockfile(...)
++# define funlockfile(...)
++# define getc_unlocked getc
++# undef off_t
++# define off_t off64_t
++# undef stat
++# define stat _stati64
++# define fstat _fstati64
++# define wstat _wstati64
++#endif
++
+ typedef struct dvd_input_s *dvd_input_t;
+
+ /**
+
diff --git a/contrib/libmkv/P00-mingw-large-file.patch b/contrib/libmkv/P00-mingw-large-file.patch
new file mode 100644
index 000000000..6a83eacca
--- /dev/null
+++ b/contrib/libmkv/P00-mingw-large-file.patch
@@ -0,0 +1,24 @@
+--- libmkv.orig/src/matroska.c 2009-01-12 23:14:26.000000000 -0800
++++ libmkv/src/matroska.c 2009-03-25 15:22:30.000000000 -0700
+@@ -27,6 +27,11 @@
+
+ #include <sys/time.h>
+
++#if defined( __MINGW32__ )
++#undef fseeko
++#define fseeko fseeko64
++#endif
++
+ #define RESERVED_SEEKHEAD 0x100
+ /* 256 bytes should be enough room for our Seek entries. */
+ #define RESERVED_CHAPTERS 0x800
+@@ -34,7 +39,7 @@
+
+ int mk_seekFile(mk_Writer *w, uint64_t pos)
+ {
+- if (fseek(w->fp, pos, SEEK_SET))
++ if (fseeko(w->fp, pos, SEEK_SET))
+ return -1;
+
+ w->f_pos = pos;
+
diff --git a/contrib/libmp4v2/P00-mingw-static.patch b/contrib/libmp4v2/P00-mingw-static.patch
new file mode 100644
index 000000000..268ff7689
--- /dev/null
+++ b/contrib/libmp4v2/P00-mingw-static.patch
@@ -0,0 +1,16 @@
+Index: mp4v2/include/mp4v2/platform.h
+===================================================================
+--- mp4v2/include/mp4v2/platform.h (revision 272)
++++ mp4v2/include/mp4v2/platform.h (working copy)
+@@ -24,8 +24,10 @@
+ #if defined( _WIN32 ) || defined( __MINGW32__ )
+ # if defined( _WINDLL ) || defined( DLL_EXPORT )
+ # define MP4V2_EXPORT __declspec(dllexport)
++# elif defined( _DLL ) || defined( DLL_IMPORT )
++# define MP4V2_EXPORT __declspec(dllimport)
+ # else
+-# define MP4V2_EXPORT __declspec(dllimport)
++# define MP4V2_EXPORT
+ # endif
+ #else
+ # define MP4V2_EXPORT __attribute__((visibility("default")))
diff --git a/contrib/libmp4v2/P01-mingw-msvcrt-lower.patch b/contrib/libmp4v2/P01-mingw-msvcrt-lower.patch
new file mode 100644
index 000000000..384542b06
--- /dev/null
+++ b/contrib/libmp4v2/P01-mingw-msvcrt-lower.patch
@@ -0,0 +1,31 @@
+diff -Naur libmp4v2.orig/libplatform/io/File_win32.cpp libmp4v2/libplatform/io/File_win32.cpp
+--- libmp4v2.orig/libplatform/io/File_win32.cpp 2008-11-16 02:50:26.000000000 -0500
++++ libmp4v2/libplatform/io/File_win32.cpp 2009-03-13 02:00:09.000000000 -0400
+@@ -8,7 +8,8 @@
+ bool
+ StdioFile::getPosition( Size& pos_ )
+ {
+- pos_ = _ftelli64( _handle );
++ fflush( _handle ); // must flush because we're using _fileno routines
++ pos_ = _telli64( _fileno( _handle ));
+ return pos_ == -1;
+ }
+
+@@ -17,6 +18,7 @@
+ bool
+ StdioFile::getSize( Size& size_ )
+ {
++ fflush( _handle ); // must flush because we're using _fileno routines
+ LARGE_INTEGER n;
+ if( !GetFileSizeEx( (HANDLE)_get_osfhandle( _fileno( _handle )), &n ))
+ return true;
+@@ -29,7 +31,8 @@
+ bool
+ StdioFile::setPosition( Size pos_ )
+ {
+- return _fseeki64( _handle, pos_, SEEK_SET ) != 0;
++ fflush( _handle ); // must flush because we're using _fileno routines
++ return _lseeki64( _fileno( _handle ), pos_, SEEK_SET ) == -1;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////
diff --git a/contrib/libmp4v2/P02-mingw-configure.patch b/contrib/libmp4v2/P02-mingw-configure.patch
new file mode 100644
index 000000000..ba749201d
--- /dev/null
+++ b/contrib/libmp4v2/P02-mingw-configure.patch
@@ -0,0 +1,26 @@
+diff -Naur libmp4v2.orig/configure.ac libmp4v2/configure.ac
+--- libmp4v2.orig/configure.ac 2009-01-10 12:44:40.000000000 -0500
++++ libmp4v2/configure.ac 2009-03-13 18:18:38.000000000 -0400
+@@ -103,11 +103,11 @@
+ X_CXX_ARCH="$X_CXX_ARCH -mwin32"
+ fi
+ ;;
+-*-*-mingw32)
++*-*-mingw*)
+ # do not support shared
+ enable_shared=no
+ X_PLATFORM=win32
+- X_MINGW_LIBS="$X_MINGW_LIBS -lmsvcr80"
++ X_MINGW_LIBS="$X_MINGW_LIBS"
+ X_CXX_W="$X_CXX_W -Wno-format"
+ if test "$enable_mingw_threads" = "yes"; then
+ X_CXX_ARCH="$X_CXX_ARCH -mthreads"
+@@ -197,7 +197,7 @@
+ case ${host} in
+ *-*-cygwin)
+ ;;
+- *-*-mingw32)
++ *-*-mingw*)
+ ;;
+ *)
+ AC_LANG(C++)
diff --git a/contrib/libmp4v2/module.defs b/contrib/libmp4v2/module.defs
index 4f950a2d5..ede60253e 100644
--- a/contrib/libmp4v2/module.defs
+++ b/contrib/libmp4v2/module.defs
@@ -5,5 +5,13 @@ LIBMP4V2.FETCH.url = http://download.m0k.org/handbrake/contrib/libmp4v2-2.0-r224
LIBMP4V2.EXTRACT.tarbase = libmp4v2
## propagate more flags
-LIBMP4V2.CONFIGURE.env.CFLAGS = CFLAGS="$(call fn.ARGS,LIBMP4V2.GCC,*archs .g .O)"
-LIBMP4V2.CONFIGURE.env.CXXFLAGS = CXXFLAGS="$(call fn.ARGS,LIBMP4V2.GCC,*archs .g .O)"
+LIBMP4V2.CONFIGURE.env.CFLAGS = CFLAGS="$(call fn.ARGS,LIBMP4V2.GCC,*archs *D .g .O)"
+LIBMP4V2.CONFIGURE.env.CXXFLAGS = CXXFLAGS="$(call fn.ARGS,LIBMP4V2.GCC,*archs *D .g .O)"
+
+## save some build-time by disabling utils
+LIBMP4V2.CONFIGURE.extra += --disable-util
+
+ifeq ($(BUILD.system),mingw)
+ ## mingw platform patches configure.ac and requires bootstrap
+ LIBMP4V2.CONFIGURE.bootstrap = autoreconf -fiv;
+endif
diff --git a/contrib/pthreadw32/module.defs b/contrib/pthreadw32/module.defs
new file mode 100644
index 000000000..0768da6cb
--- /dev/null
+++ b/contrib/pthreadw32/module.defs
@@ -0,0 +1,25 @@
+$(eval $(call import.MODULE.defs,PTHREADW32,pthreadw32))
+$(eval $(call import.CONTRIB.defs,PTHREADW32))
+
+PTHREADW32.FETCH.url = http://download.m0k.org/handbrake/contrib/pthreads-w32-2-8-0-release.tar.gz
+
+PTHREADW32.CONFIGURE = $(TOUCH.exe) $@
+
+PTHREADW32.BUILD.extra = CROSS=$(BUILD.cross.prefix) clean GC-static
+PTHREADW32.BUILD.ntargets = clean GC-static
+
+define PTHREADW32.INSTALL
+ $(CP.exe) $(PTHREADW32.EXTRACT.dir/)libpthreadGC2.a $(CONTRIB.build/)lib/
+ $(CP.exe) $(PTHREADW32.EXTRACT.dir/)pthread.h $(CONTRIB.build/)include/
+ $(CP.exe) $(PTHREADW32.EXTRACT.dir/)sched.h $(CONTRIB.build/)include/
+ $(CP.exe) $(PTHREADW32.EXTRACT.dir/)semaphore.h $(CONTRIB.build/)include/
+ $(TOUCH.exe) $@
+endef
+
+define PTHREADW32.UNINSTALL
+ $(RM.exe) -f $(CONTRIB.build/)lib/libpthreadGC2.a
+ $(RM.exe) -f $(CONTRIB.build/)include/pthread.h
+ $(RM.exe) -f $(CONTRIB.build/)include/sched.h
+ $(RM.exe) -f $(CONTRIB.build/)include/semaphore.h
+ $(RM.exe) -f $(PTHREADW32.INSTALL.target)
+endef
diff --git a/contrib/pthreadw32/module.rules b/contrib/pthreadw32/module.rules
new file mode 100644
index 000000000..78448835e
--- /dev/null
+++ b/contrib/pthreadw32/module.rules
@@ -0,0 +1,2 @@
+$(eval $(call import.MODULE.rules,PTHREADW32))
+$(eval $(call import.CONTRIB.rules,PTHREADW32))
diff --git a/contrib/x264/module.defs b/contrib/x264/module.defs
index 93430a4e1..c1009d938 100644
--- a/contrib/x264/module.defs
+++ b/contrib/x264/module.defs
@@ -1,4 +1,4 @@
-$(eval $(call import.MODULE.defs,X264,x264))
+$(eval $(call import.MODULE.defs,X264,x264,PTHREADW32))
$(eval $(call import.CONTRIB.defs,X264))
X264.FETCH.url = http://download.m0k.org/handbrake/contrib/x264-r1130-8475977.tar.gz
@@ -8,4 +8,12 @@ X264.CONFIGURE.deps =
X264.CONFIGURE.shared =
X264.CONFIGURE.static =
-X264.CONFIGURE.extra = --disable-mp4-output --enable-pthread
+X264.CONFIGURE.extra = --disable-mp4-output
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+ X264.CONFIGURE.extra += --enable-pthread --cross-prefix=$(BUILD.spec)-
+ X264.CONFIGURE.env.CFLAGS = CFLAGS="-I$(call fn.ABSOLUTE,$(CONTRIB.build/)include) $(call fn.ARGS,X264.GCC,*archs ?extra)"
+ X264.CONFIGURE.env.LDFLAGS = LDFLAGS=-L$(call fn.ABSOLUTE,$(CONTRIB.build/)lib)
+else
+ X264.CONFIGURE.extra += --enable-pthread
+endif
diff --git a/contrib/xvidcore/A00-nasm.patch b/contrib/xvidcore/A00-nasm.patch
deleted file mode 100644
index 44242ace4..000000000
--- a/contrib/xvidcore/A00-nasm.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff -ruN xvidcore-orig/build/generic/configure xvidcore/build/generic/configure
---- xvidcore-orig/build/generic/configure 2006-11-01 03:39:36.000000000 -0700
-+++ xvidcore/build/generic/configure 2008-01-30 20:19:48.000000000 -0700
-@@ -4016,7 +4016,7 @@
- if test "$ac_nasm" = "yes" ; then
- echo "$as_me:$LINENO: checking for nasm patch version" >&5
- echo $ECHO_N "checking for nasm patch version... $ECHO_C" >&6
-- nasm_patch=`$nasm_prog -r | cut -d '.' -f 3 | cut -d ' ' -f 1`
-+ nasm_patch=`($nasm_prog -r || $nasm_prog -v) | cut -d '.' -f 3 | cut -d ' ' -f 1`
- if test -z $nasm_patch ; then
-- nasm_patch=-1
-+ nasm_patch=45
- fi
diff --git a/contrib/xvidcore/A01-fdct.patch b/contrib/xvidcore/A01-fdct.patch
deleted file mode 100644
index 1fc90b689..000000000
--- a/contrib/xvidcore/A01-fdct.patch
+++ /dev/null
@@ -1,8 +0,0 @@
---- xvidcore/src/dct/x86_asm/fdct_sse2_skal.asm.orig 2008-02-22 10:28:13.000000000 -0800
-+++ xvidcore/src/dct/x86_asm/fdct_sse2_skal.asm 2008-02-22 11:08:52.000000000 -0800
-@@ -620,3 +620,5 @@
- ret
- .endfunc
-
-+ALIGN 16
-+ times 8 dw 0
diff --git a/contrib/xvidcore/P00-darwin.patch b/contrib/xvidcore/P00-darwin.patch
index 51cb94c6d..12bc8dac0 100644
--- a/contrib/xvidcore/P00-darwin.patch
+++ b/contrib/xvidcore/P00-darwin.patch
@@ -1,31 +1,31 @@
-diff -ru xvidcore-1.1.0/build/generic/configure xvidcore-1.1.0-patched/build/generic/configure
---- xvidcore-1.1.0/build/generic/configure 2005-12-30 15:45:30.000000000 +0100
-+++ xvidcore-1.1.0-patched/build/generic/configure 2006-01-16 22:06:10.000000000 +0100
-@@ -4052,6 +4071,12 @@
- PREFIX="-DPREFIX"
+diff -Naur xvidcore-20090311.orig/build/generic/configure.in xvidcore-20090311/build/generic/configure.in
+--- xvidcore-20090311.orig/build/generic/configure.in 2008-12-05 05:18:52.000000000 -0500
++++ xvidcore-20090311/build/generic/configure.in 2009-04-14 11:30:04.000000000 -0400
+@@ -427,8 +427,13 @@
MARK_FUNCS=""
;;
-+ *darwin*)
-+ echo "$as_me:$LINENO: result: macho" >&5
-+echo "${ECHO_T}macho" >&6
-+ NASM_FORMAT="macho"
-+ PREFIX="-DPREFIX"
-+ MARK_FUNCS=""
- esac
-
- AS="$chosen_asm_prog"
-diff -ru xvidcore-1.1.0/build/generic/configure.in xvidcore-1.1.0-patched/build/generic/configure.in
---- xvidcore-1.1.0/build/generic/configure.in 2005-12-30 15:45:30.000000000 +0100
-+++ xvidcore-1.1.0-patched/build/generic/configure.in 2006-01-16 22:06:04.000000000 +0100
-@@ -397,6 +397,11 @@
- PREFIX="-DPREFIX"
- MARK_FUNCS=""
+ *darwin*)
+- AC_MSG_RESULT([macho])
+- NASM_FORMAT="macho"
++ if test "$ARCHITECTURE" = "X86_64" ; then
++ AC_MSG_RESULT([macho64])
++ NASM_FORMAT="macho64"
++ else
++ AC_MSG_RESULT([macho])
++ NASM_FORMAT="macho"
++ fi
+ PREFIX="-DPREFIX"
+ MARK_FUNCS=""
;;
-+ *darwin*)
-+ AC_MSG_RESULT([macho])
-+ NASM_FORMAT="macho"
-+ PREFIX="-DPREFIX"
-+ MARK_FUNCS=""
- esac
-
- AS="$chosen_asm_prog"
+diff -Naur xvidcore-20090311.orig/src/nasm.inc xvidcore-20090311/src/nasm.inc
+--- xvidcore-20090311.orig/src/nasm.inc 2008-12-05 05:15:02.000000000 -0500
++++ xvidcore-20090311/src/nasm.inc 2009-04-14 12:13:37.000000000 -0400
+@@ -177,6 +177,8 @@
+ %macro TEXT 0
+ %ifidn __OUTPUT_FORMAT__,macho
+ SECTION .text align=SECTION_ALIGN
++%elifidn __OUTPUT_FORMAT__,macho64
++ SECTION .text align=SECTION_ALIGN
+ %else
+ SECTION .rotext align=SECTION_ALIGN
+ %endif
diff --git a/contrib/xvidcore/P01-cygwin.patch b/contrib/xvidcore/P01-cygwin.patch
index 7b60510d0..20afce260 100644
--- a/contrib/xvidcore/P01-cygwin.patch
+++ b/contrib/xvidcore/P01-cygwin.patch
@@ -1,24 +1,7 @@
-diff -Naur xvidcore/build/generic/configure xvidcore-patched/build/generic/configure
---- xvidcore/build/generic/configure 2005-12-30 09:45:30.000000000 -0500
-+++ xvidcore-patched/build/generic/configure 2007-01-01 18:43:27.953125000 -0500
-@@ -3844,10 +3844,9 @@
- [cC][yY][gG][wW][iI][nN]*|mingw32*|mks*)
- echo "$as_me:$LINENO: result: ok" >&5
- echo "${ECHO_T}ok" >&6
-- STATIC_LIB="xvidcore.\$(STATIC_EXTENSION)"
-- SHARED_LIB="xvidcore.\$(SHARED_EXTENSION)"
-- SPECIFIC_LDFLAGS="-mno-cygwin -shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def"
-- SPECIFIC_CFLAGS="-mno-cygwin"
-+ STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)"
-+ SHARED_LIB="libxvidcore.\$(SHARED_EXTENSION)"
-+ SPECIFIC_LDFLAGS="-shared -Wl,--dll,--out-implib,\[email protected] libxvidcore.def"
- ;;
- darwin*|raphsody*)
- STATIC_LIB="libxvidcore.\$(STATIC_EXTENSION)"
-diff -Naur xvidcore/build/generic/configure.in xvidcore-patched/build/generic/configure.in
---- xvidcore/build/generic/configure.in 2005-12-30 09:45:30.000000000 -0500
-+++ xvidcore-patched/build/generic/configure.in 2007-01-01 18:43:11.453125000 -0500
-@@ -281,10 +281,9 @@
+diff -Naur xvidcore-20090311.orig/build/generic/configure.in xvidcore-20090311/build/generic/configure.in
+--- xvidcore-20090311.orig/build/generic/configure.in 2008-12-05 05:18:52.000000000 -0500
++++ xvidcore-20090311/build/generic/configure.in 2009-04-14 13:18:23.034051500 -0400
+@@ -282,10 +282,9 @@
;;
[[cC]][[yY]][[gG]][[wW]][[iI]][[nN]]*|mingw32*|mks*)
AC_MSG_RESULT([ok])
diff --git a/contrib/xvidcore/module.defs b/contrib/xvidcore/module.defs
index dee8b3e45..5a76e0911 100644
--- a/contrib/xvidcore/module.defs
+++ b/contrib/xvidcore/module.defs
@@ -1,15 +1,19 @@
$(eval $(call import.MODULE.defs,XVIDCORE,xvidcore))
$(eval $(call import.CONTRIB.defs,XVIDCORE))
-XVIDCORE.FETCH.url = http://download.m0k.org/handbrake/contrib/xvidcore-1.1.3.tar.gz
-XVIDCORE.EXTRACT.tarbase = xvidcore
+XVIDCORE.FETCH.url = http://download.m0k.org/handbrake/contrib/xvidcore-20090311.tar.gz
+XVIDCORE.CONFIGURE.static =
+XVIDCORE.CONFIGURE.shared =
+XVIDCORE.CONFIGURE.deps =
XVIDCORE.CONFIGURE.dir = $(XVIDCORE.EXTRACT.dir/)build/generic/
+XVIDCORE.CONFIGURE.bootstrap = ./bootstrap.sh;
XVIDCORE.BUILD.dir = $(XVIDCORE.EXTRACT.dir/)build/generic/
+XVIDCORE.BUILD.extra = STATIC_LIB=libxvidcore.a
XVIDCORE.BUILD.ntargets = libxvidcore.a
-XVIDCORE.CLEAN.dir = $(XVIDCORE.EXTRACT.dir/)build/generic/
+XVIDCORE.CLEAN.dir = $(XVIDCORE.EXTRACT.dir/)build/generic/
define XVIDCORE.INSTALL
$(CP.exe) $(XVIDCORE.EXTRACT.dir/)build/generic/=build/libxvidcore.a $(CONTRIB.build/)lib/
diff --git a/contrib/zlib/module.defs b/contrib/zlib/module.defs
index 66db2f491..55daf6d8e 100644
--- a/contrib/zlib/module.defs
+++ b/contrib/zlib/module.defs
@@ -4,3 +4,9 @@ $(eval $(call import.CONTRIB.defs,ZLIB))
ZLIB.FETCH.url = http://download.m0k.org/handbrake/contrib/zlib-1.2.3.tar.gz
ZLIB.EXTRACT.tarbase = zlib
ZLIB.CONFIGURE.args = !sete @dir !env !exe @prefix !extra
+
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+ ZLIB.CONFIGURE.env.AR = AR="$(AR.exe) rc"
+ ZLIB.CONFIGURE.env.RANLIB = RANLIB="$(RANLIB.exe)"
+ ZLIB.CONFIGURE.env.args += !AR !RANLIB
+endif
diff --git a/libhb/common.h b/libhb/common.h
index 1fa3d4fe1..b7c468672 100644
--- a/libhb/common.h
+++ b/libhb/common.h
@@ -18,6 +18,20 @@
#include <sys/stat.h>
#include <dirent.h>
+#if defined( SYS_MINGW )
+# define fseek fseeko64
+# define ftell ftello64
+# undef fseeko
+# define fseeko fseeko64
+# undef ftello
+# define ftello ftello64
+# define flockfile(...)
+# define funlockfile(...)
+# define getc_unlocked getc
+# undef off_t
+# define off_t off64_t
+#endif
+
#ifndef MIN
#define MIN( a, b ) ( (a) > (b) ? (b) : (a) )
#endif
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 532059706..8b09afcf7 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -401,7 +401,7 @@ static int decavcodecBSInfo( hb_work_object_t *w, const hb_buffer_t *buf,
AVCodecParserContext *parser = av_parser_init( codec->id );
AVCodecContext *context = avcodec_alloc_context();
hb_avcodec_open( context, codec );
-#ifdef SYS_CYGWIN
+#if defined( SYS_CYGWIN )
uint8_t *buffer = memalign(16, AVCODEC_MAX_AUDIO_FRAME_SIZE);
#else
uint8_t *buffer = malloc( AVCODEC_MAX_AUDIO_FRAME_SIZE );
@@ -1132,7 +1132,7 @@ static void decodeAudio( hb_work_private_t *pv, uint8_t *data, int size )
// complicated, machine dependent alignment here we use the
// fact that malloc returns an aligned pointer on most architectures.
- #ifdef SYS_CYGWIN
+ #if defined( SYS_CYGWIN )
// Cygwin's malloc doesn't appear to return 16-byte aligned memory so use memalign instead.
pv->buffer = memalign(16, AVCODEC_MAX_AUDIO_FRAME_SIZE);
#else
diff --git a/libhb/decmetadata.c b/libhb/decmetadata.c
index 235fc69fd..85c3cd28b 100644
--- a/libhb/decmetadata.c
+++ b/libhb/decmetadata.c
@@ -130,7 +130,7 @@ static void decmp4metadata( hb_title_t *title )
MP4ChapterTypeQt );
if( chapter_list && ( hb_list_count( title->list_chapter ) == 0 ) ) {
- uint i = 1;
+ uint32_t i = 1;
while( i <= chapter_count )
{
hb_chapter_t * chapter;
diff --git a/libhb/fifo.c b/libhb/fifo.c
index 9441f7172..c756f5673 100644
--- a/libhb/fifo.c
+++ b/libhb/fifo.c
@@ -147,7 +147,7 @@ hb_buffer_t * hb_buffer_init( int size )
if (size)
{
-#if defined( SYS_DARWIN ) || defined( SYS_FREEBSD )
+#if defined( SYS_DARWIN ) || defined( SYS_FREEBSD ) || defined( SYS_MINGW )
b->data = malloc( b->alloc );
#elif defined( SYS_CYGWIN )
/* FIXME */
diff --git a/libhb/module.defs b/libhb/module.defs
index e3942f781..dc2fb1ad5 100644
--- a/libhb/module.defs
+++ b/libhb/module.defs
@@ -1,6 +1,12 @@
-$(eval $(call import.MODULE.defs,LIBHB,libhb,A52DEC BZIP2 FAAC FAAD2 FFMPEG LAME LIBDCA LIBDVDREAD LIBMKV LIBMP4V2 LIBOGG LIBSAMPLERATE LIBTHEORA LIBVORBIS MPEG2DEC X264 XVIDCORE ZLIB LIBHB TEST DOC))
+__deps__ := A52DEC BZIP2 FAAC FAAD2 FFMPEG LAME LIBDCA \
+ LIBDVDREAD LIBMKV LIBMP4V2 LIBOGG LIBSAMPLERATE LIBTHEORA \
+ LIBVORBIS MPEG2DEC PTHREADW32 X264 XVIDCORE ZLIB
+
+$(eval $(call import.MODULE.defs,LIBHB,libhb,$(__deps__)))
$(eval $(call import.GCC,LIBHB))
+###############################################################################
+
LIBHB.src/ = $(SRC/)libhb/
LIBHB.build/ = $(BUILD/)libhb/
@@ -10,10 +16,7 @@ LIBHB.m4.out = $(patsubst $(LIBHB.src/)%.m4,$(LIBHB.build/)%,$(LIBHB.m4.in))
LIBHB.c = $(wildcard $(LIBHB.src/)*.c)
LIBHB.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%.o,$(LIBHB.c))
LIBHB.d = $(LIBHB.m4.out) $(LIBHB.h.out) \
- $(foreach n, \
- A52DEC BZIP2 FAAC FAAD2 FFMPEG LAME LIBDCA LIBDVDREAD LIBMKV LIBMP4V2 LIBOGG \
- LIBSAMPLERATE LIBTHEORA LIBVORBIS MPEG2DEC X264 XVIDCORE ZLIB, \
- $($n.INSTALL.target) )
+ $(foreach n,$(LIBHB.prerequisites),$($n.INSTALL.target) )
LIBHB.h.in = $(wildcard $(LIBHB.src/)*.h)
LIBHB.h.out = $(patsubst $(SRC/)%,$(BUILD/)%,$(LIBHB.h.in))
@@ -40,6 +43,8 @@ else ifeq ($(BUILD.system),darwin)
LIBHB.GCC.D += SYS_DARWIN
else ifeq ($(BUILD.system),linux)
LIBHB.GCC.D += SYS_LINUX _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64
+else ifeq ($(BUILD.system),mingw)
+ LIBHB.GCC.D += SYS_MINGW PTW32_STATIC_LIB
else ifeq ($(BUILD.system),solaris)
LIBHB.GCC.D += SYS_SunOS _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64
else
@@ -76,4 +81,22 @@ endif
###############################################################################
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+
+LIBHB.dll = $(LIBHB.build/)hb.dll
+LIBHB.lib = $(LIBHB.build/)hb.lib
+
+LIBHB.dll.libs = $(foreach n, \
+ a52 bz2 avcodec avformat avutil dca dvdread faac faad mkv mpeg2 mp3lame mp4v2 \
+ ogg pthreadGC2 samplerate swscale theora vorbis vorbisenc x264 xvidcore z, \
+ $(CONTRIB.build/)lib/lib$(n).a )
+
+LIBHB.GCC.args.extra.dylib++ = -Wl,--out-implib,$(LIBHB.lib)
+LIBHB.GCC.l += iberty ws2_32
+LIBHB.out += $(LIBHB.dll) $(LIBHB.lib)
+
+endif
+
+###############################################################################
+
BUILD.out += $(LIBHB.out)
diff --git a/libhb/module.rules b/libhb/module.rules
index 8f63a143f..c92ababa2 100644
--- a/libhb/module.rules
+++ b/libhb/module.rules
@@ -36,5 +36,17 @@ endif
###############################################################################
+ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+
+libhb.build: $(LIBHB.dll)
+
+$(LIBHB.dll): | $(dirname $(LIBHB.dll) $(LIBHB.lib))
+$(LIBHB.dll): $(LIBHB.c.o) $(LIBHB.yasm.o)
+ $(call LIBHB.GCC.DYLIB++,$@,$^ $(LIBHB.dll.libs))
+
+endif
+
+###############################################################################
+
clean: libhb.clean
build: libhb.build
diff --git a/libhb/ports.c b/libhb/ports.c
index 1d2c4923f..2e6b65329 100644
--- a/libhb/ports.c
+++ b/libhb/ports.c
@@ -31,6 +31,11 @@
#include <windows.h>
#endif
+#ifdef SYS_MINGW
+#include <pthread.h>
+#include <windows.h>
+#endif
+
#ifdef SYS_SunOS
#include <sys/processor.h>
#endif
@@ -39,15 +44,15 @@
#include <sys/time.h>
-//#ifdef SYS_CYGWIN
-//#include <winsock2.h>
-//#include <ws2tcpip.h>
-//#else
+#ifdef SYS_MINGW
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
-//#endif
+#endif
#include "hb.h"
@@ -97,7 +102,7 @@ void hb_snooze( int delay )
snooze( 1000 * delay );
#elif defined( SYS_DARWIN ) || defined( SYS_LINUX ) || defined( SYS_FREEBSD) || defined( SYS_SunOS )
usleep( 1000 * delay );
-#elif defined( SYS_CYGWIN )
+#elif defined( SYS_CYGWIN ) || defined( SYS_MINGW )
Sleep( delay );
#endif
}
@@ -119,7 +124,7 @@ int hb_get_cpu_count()
}
cpu_count = 1;
-#if defined(SYS_CYGWIN)
+#if defined(SYS_CYGWIN) || defined(SYS_MINGW)
SYSTEM_INFO cpuinfo;
GetSystemInfo( &cpuinfo );
cpu_count = cpuinfo.dwNumberOfProcessors;
@@ -181,7 +186,7 @@ void hb_get_tempory_directory( hb_handle_t * h, char path[512] )
char base[512];
/* Create the base */
-#ifdef SYS_CYGWIN
+#if defined( SYS_CYGWIN ) || defined( SYS_MINGW )
char *p;
int i_size = GetTempPath( 512, base );
if( i_size <= 0 || i_size >= 512 )
@@ -227,11 +232,11 @@ void hb_get_tempory_filename( hb_handle_t * h, char name[1024],
***********************************************************************/
void hb_mkdir( char * name )
{
-//#ifdef SYS_CYGWIN
-// mkdir( name );
-//#else
+#ifdef SYS_MINGW
+ mkdir( name );
+#else
mkdir( name, 0755 );
-//#endif
+#endif
}
/************************************************************************
diff --git a/libhb/ports.h b/libhb/ports.h
index 9c2143944..c544f19a6 100644
--- a/libhb/ports.h
+++ b/libhb/ports.h
@@ -43,6 +43,9 @@ typedef struct hb_thread_s hb_thread_t;
#elif defined( SYS_CYGWIN )
# define HB_LOW_PRIORITY 0
# define HB_NORMAL_PRIORITY 1
+#elif defined( SYS_MINGW )
+# define HB_LOW_PRIORITY 0
+# define HB_NORMAL_PRIORITY 0
#endif
hb_thread_t * hb_thread_init( char * name, void (* function)(void *),
diff --git a/libhb/reader.c b/libhb/reader.c
index 7b44a6500..8c5ecdd2a 100644
--- a/libhb/reader.c
+++ b/libhb/reader.c
@@ -27,7 +27,7 @@ typedef struct
int64_t scr_offset;
hb_psdemux_t demux;
int scr_changes;
- uint sequence;
+ uint32_t sequence;
uint8_t st_slots; // size (in slots) of stream_timing array
uint8_t saw_video; // != 0 if we've seen video
uint8_t saw_audio; // != 0 if we've seen audio
diff --git a/make/configure.py b/make/configure.py
index 26a1dc118..ba089411a 100644
--- a/make/configure.py
+++ b/make/configure.py
@@ -315,7 +315,7 @@ class ShellProbe( Action ):
## x86_64-unknown-linux-gnu (Linux, Fedora 10 x86_64)
##
class HostTupleProbe( ShellProbe, list ):
- GNU_TUPLE_RX = '([^-]+)-([^-]+)-([^0-9-]+)([^-]*)-?([^-]*)'
+ GNU_TUPLE_RE = '([^-]+)-?([^-]*)-([^0-9-]+)([^-]*)-?([^-]*)'
def __init__( self ):
super( HostTupleProbe, self ).__init__( 'host tuple', '%s/config.guess' % (cfg.dir), abort=True, head=True )
@@ -327,7 +327,7 @@ class HostTupleProbe( ShellProbe, list ):
self.spec = ''
## grok GNU host tuples
- m = re.match( HostTupleProbe.GNU_TUPLE_RX, self.spec )
+ m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec )
if not m:
self.fail = True
self.msg_end = 'invalid host tuple: %s' % (self.spec)
@@ -365,10 +365,14 @@ class BuildAction( Action, list ):
super( BuildAction, self ).__init__( 'compute', 'build tuple', abort=True )
def _action( self ):
- self.spec = arch.mode[arch.mode.mode]
+ ## check if --cross spec was used; must maintain 5-tuple compatibility with regex
+ if options.cross:
+ self.spec = os.path.basename( options.cross ).rstrip( '-' )
+ else:
+ self.spec = arch.mode[arch.mode.mode]
## grok GNU host tuples
- m = re.match( HostTupleProbe.GNU_TUPLE_RX, self.spec )
+ m = re.match( HostTupleProbe.GNU_TUPLE_RE, self.spec )
if not m:
self.msg_end = 'invalid host tuple: %s' % (self.spec)
return
@@ -386,6 +390,15 @@ class BuildAction( Action, list ):
self.extra = self[4]
self.systemf = host.systemf
+ ## when cross we need switch for platforms
+ if options.cross:
+ if self.match( '*mingw*' ):
+ self.systemf = 'MinGW'
+ elif self.systemf:
+ self.systemf[0] = self.systemf[0].upper()
+ self.title = '%s %s' % (build.systemf,self.machine)
+ else:
+ self.title = '%s %s' % (build.systemf,arch.mode.mode)
self.fail = False
## glob-match against spec
@@ -629,7 +642,7 @@ class Project( Action ):
self.name = 'HandBrake'
self.acro_lower = 'hb'
self.acro_upper = 'HB'
- self.url_website = 'http://handbrake.fr'
+ self.url_website = 'http://code.google.com/p/hbfork'
self.url_community = 'http://forum.handbrake.fr'
self.url_irc = 'irc://irc.freenode.net/handbrake'
@@ -783,9 +796,15 @@ class ConfigDocument:
def _outputMake( self, file, namelen, name, value, append ):
if append:
- file.write( '%-*s += %s\n' % (namelen, name, value ))
+ if value == None or len(str(value)) == 0:
+ file.write( '%-*s +=\n' % (namelen, name) )
+ else:
+ file.write( '%-*s += %s\n' % (namelen, name, value) )
else:
- file.write( '%-*s = %s\n' % (namelen, name, value ))
+ if value == None or len(str(value)) == 0:
+ file.write( '%-*s =\n' % (namelen, name) )
+ else:
+ file.write( '%-*s = %s\n' % (namelen, name, value) )
def _outputM4( self, file, namelen, name, value ):
namelen += 7
@@ -930,6 +949,8 @@ def createCLI():
h = IfHost( 'disable GTK GUI', '*-*-linux*', none=optparse.SUPPRESS_HELP ).value
grp.add_option( '--disable-gtk', default=False, action='store_true', help=h )
+ h = IfHost( 'enable GTK GUI (mingw)', '*-*-mingw*', none=optparse.SUPPRESS_HELP ).value
+ grp.add_option( '--enable-gtk-mingw', default=False, action='store_true', help=h )
h = IfHost( 'disable Xcode', '*-*-darwin*', none=optparse.SUPPRESS_HELP ).value
grp.add_option( '--disable-xcode', default=False, action='store_true', help=h )
@@ -953,6 +974,8 @@ def createCLI():
debugMode.cli_add_option( grp, '--debug' )
optimizeMode.cli_add_option( grp, '--optimize' )
arch.mode.cli_add_option( grp, '--arch' )
+ grp.add_option( '--cross', default=None, action='store', metavar='SPEC',
+ help='specify GCC cross-compilation spec' )
cli.add_option_group( grp )
## add tool locations
@@ -1100,13 +1123,15 @@ try:
else:
gmake = ToolProbe( 'GMAKE.exe', 'gmake', 'make' )
- m4 = ToolProbe( 'M4.exe', 'm4' )
- mkdir = ToolProbe( 'MKDIR.exe', 'mkdir' )
- patch = ToolProbe( 'PATCH.exe', 'gpatch', 'patch' )
- rm = ToolProbe( 'RM.exe', 'rm' )
- tar = ToolProbe( 'TAR.exe', 'gtar', 'tar' )
- wget = ToolProbe( 'WGET.exe', 'wget', abort=False )
- yasm = ToolProbe( 'YASM.exe', 'yasm', abort=False )
+ m4 = ToolProbe( 'M4.exe', 'm4' )
+ mkdir = ToolProbe( 'MKDIR.exe', 'mkdir' )
+ patch = ToolProbe( 'PATCH.exe', 'gpatch', 'patch' )
+ rm = ToolProbe( 'RM.exe', 'rm' )
+ ranlib = ToolProbe( 'RANLIB.exe', 'ranlib' )
+ strip = ToolProbe( 'STRIP.exe', 'strip' )
+ tar = ToolProbe( 'TAR.exe', 'gtar', 'tar' )
+ wget = ToolProbe( 'WGET.exe', 'wget', abort=False )
+ yasm = ToolProbe( 'YASM.exe', 'yasm', abort=False )
xcodebuild = ToolProbe( 'XCODEBUILD.exe', 'xcodebuild', abort=False )
lipo = ToolProbe( 'LIPO.exe', 'lipo', abort=False )
@@ -1140,6 +1165,12 @@ try:
else:
targets.append( arg )
+ ## re-run tools with cross-compilation needs
+ if options.cross:
+ for tool in ( Tools.ar, Tools.gcc, Tools.ranlib, Tools.strip ):
+ tool.__init__( tool.var, '%s-%s' % (options.cross,tool.name), **tool.kwargs )
+ tool.run()
+
## run delayed actions
for action in Action.actions:
action.run()
@@ -1207,14 +1238,19 @@ try:
doc.add( 'BUILD.systemf', build.systemf )
doc.add( 'BUILD.release', build.release )
doc.add( 'BUILD.extra', build.extra )
- doc.add( 'BUILD.title', '%s %s' % (build.systemf,arch.mode.mode) )
+ doc.add( 'BUILD.title', build.title )
doc.add( 'BUILD.ncpu', core.count )
doc.add( 'BUILD.jobs', core.jobs )
- doc.add( 'BUILD.cross', int(arch.mode.mode != arch.mode.default) )
- doc.add( 'BUILD.method', 'terminal' )
- doc.add( 'BUILD.date', time.strftime('%c') )
- doc.add( 'BUILD.arch', arch.mode.mode )
+ doc.add( 'BUILD.cross', int(options.cross != None or arch.mode.mode != arch.mode.default) )
+ if options.cross:
+ doc.add( 'BUILD.cross.prefix', '%s-' % (options.cross) )
+ else:
+ doc.add( 'BUILD.cross.prefix', '' )
+
+ doc.add( 'BUILD.method', 'terminal' )
+ doc.add( 'BUILD.date', time.strftime('%c') )
+ doc.add( 'BUILD.arch', arch.mode.mode )
doc.addBlank()
doc.add( 'CONF.method', options.conf_method )
@@ -1230,7 +1266,8 @@ try:
doc.addBlank()
doc.add( 'FEATURE.asm', 'disabled' )
doc.add( 'FEATURE.gtk', int( not options.disable_gtk ))
- doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode) ))
+ doc.add( 'FEATURE.gtk.mingw', int( options.enable_gtk_mingw ))
+ doc.add( 'FEATURE.xcode', int( not (Tools.xcodebuild.fail or options.disable_xcode or options.cross) ))
if not Tools.xcodebuild.fail and not options.disable_xcode:
doc.addBlank()
diff --git a/make/include/contrib.defs b/make/include/contrib.defs
index cbc70866b..a3019ade7 100644
--- a/make/include/contrib.defs
+++ b/make/include/contrib.defs
@@ -83,10 +83,10 @@ define import.CONTRIB.defs
$(1).CONFIGURE.args = !sete @dir !bootstrap !env !exe @host @prefix !deps !shared !static !extra
$(1).CONFIGURE.env.CC = CC=$$($(1).GCC.gcc)
- $(1).CONFIGURE.env.CFLAGS = CFLAGS="$$(call fn.ARGS,$(1).GCC,*archs)"
+ $(1).CONFIGURE.env.CFLAGS = CFLAGS="$$(call fn.ARGS,$(1).GCC,*archs ?extra)"
$(1).CONFIGURE.env.CXX = CXX=$$($(1).GCC.gxx)
- $(1).CONFIGURE.env.CXXFLAGS = CXXFLAGS="$$(call fn.ARGS,$(1).GCC,*archs)"
- $(1).CONFIGURE.env.CPPFLAGS = CPPFLAGS="$$(call fn.ARGS,$(1).GCC,*archs)"
+ $(1).CONFIGURE.env.CXXFLAGS = CXXFLAGS="$$(call fn.ARGS,$(1).GCC,*archs ?extra)"
+ $(1).CONFIGURE.env.CPPFLAGS = CPPFLAGS="$$(call fn.ARGS,$(1).GCC,*archs ?extra)"
$(1).CONFIGURE.env.LDFLAGS = LDFLAGS="$$(call fn.ARGS,$(1).GCC,*archs)"
$(1).CONFIGURE.env.args = !CC !CFLAGS !CXX !CXXFLAGS !CPPFLAGS !LDFLAGS
diff --git a/make/include/gcc.defs b/make/include/gcc.defs
index 35a6e50a8..f9511d1b5 100644
--- a/make/include/gcc.defs
+++ b/make/include/gcc.defs
@@ -12,7 +12,6 @@ GCC.vis = 0
GCC.pic = 0
GCC.g = none
GCC.O = none
-GCC.extra = 1
GCC.D =
GCC.I =
GCC.muldefs = 0
@@ -24,6 +23,16 @@ GCC.L =
GCC.l =
GCC.end = 0
+GCC.extra = 1
+GCC.extra.h_o = 1
+GCC.extra.c_o = 1
+GCC.extra.dylib = 1
+GCC.extra.exe = 1
+GCC.extra.hpp_o = 1
+GCC.extra.cpp_o = 1
+GCC.extra.dylib++ = 1
+GCC.extra.exe++ = 1
+
GCC.args.pipe = -pipe
GCC.args.strip = -Wl,-S
GCC.args.dylib = -dynamiclib
@@ -40,7 +49,6 @@ GCC.args.g.max = -gdwarf-2 -g3
GCC.args.O.none = -O0
GCC.args.O.size = -Os
GCC.args.O.speed = -O3
-GCC.args.extra =
GCC.args.D = -D$(1)
GCC.args.I = -I$(1)
GCC.args.muldefs = -Wl,--allow-multiple-definition
@@ -51,6 +59,16 @@ GCC.args.L = -L$(1)
GCC.args.l = -l$(1)
GCC.args.end = -Wl,--end-group
+GCC.args.extra =
+GCC.args.extra.h_o =
+GCC.args.extra.c_o =
+GCC.args.extra.dylib =
+GCC.args.extra.exe =
+GCC.args.extra.hpp_o =
+GCC.args.extra.cpp_o =
+GCC.args.extra.dylib++ =
+GCC.args.extra.exe++ =
+
###############################################################################
define import.GCC
@@ -68,7 +86,6 @@ define import.GCC
$(1).GCC.pic = $$(GCC.pic)
$(1).GCC.g = $$(GCC.g)
$(1).GCC.O = $$(GCC.O)
- $(1).GCC.extra = $$(GCC.extra)
$(1).GCC.D = $$(GCC.D)
$(1).GCC.I = $$(GCC.I)
$(1).GCC.muldefs = $$(GCC.muldefs)
@@ -80,6 +97,16 @@ define import.GCC
$(1).GCC.l = $$(GCC.l)
$(1).GCC.end = $$(GCC.end)
+ $(1).GCC.extra = $$(GCC.extra)
+ $(1).GCC.extra.h_o = $$(GCC.extra.h_o)
+ $(1).GCC.extra.c_o = $$(GCC.extra.c_o)
+ $(1).GCC.extra.dylib = $$(GCC.extra.dylib)
+ $(1).GCC.extra.exe = $$(GCC.extra.exe)
+ $(1).GCC.extra.hpp_o = $$(GCC.extra.hpp_o)
+ $(1).GCC.extra.cpp_o = $$(GCC.extra.cpp_o)
+ $(1).GCC.extra.dylib++ = $$(GCC.extra.dylib++)
+ $(1).GCC.extra.exe++ = $$(GCC.extra.exe++)
+
$(1).GCC.args.pipe = $$(GCC.args.pipe)
$(1).GCC.args.strip = $$(GCC.args.strip)
$(1).GCC.args.dylib = $$(GCC.args.dylib)
@@ -96,7 +123,6 @@ define import.GCC
$(1).GCC.args.O.none = $$(GCC.args.O.none)
$(1).GCC.args.O.size = $$(GCC.args.O.size)
$(1).GCC.args.O.speed = $$(GCC.args.O.speed)
- $(1).GCC.args.extra = $$(GCC.args.extra)
$(1).GCC.args.D = $$(GCC.args.D)
$(1).GCC.args.I = $$(GCC.args.I)
$(1).GCC.args.muldefs = $$(GCC.args.muldefs)
@@ -107,25 +133,35 @@ define import.GCC
$(1).GCC.args.l = $$(GCC.args.l)
$(1).GCC.args.end = $$(GCC.args.end)
+ $(1).GCC.args.extra = $$(GCC.args.extra)
+ $(1).GCC.args.extra.h_o = $$(GCC.args.extra.h_o)
+ $(1).GCC.args.extra.c_o = $$(GCC.args.extra.c_o)
+ $(1).GCC.args.extra.dylib = $$(GCC.args.extra.dylib)
+ $(1).GCC.args.extra.exe = $$(GCC.args.extra.exe)
+ $(1).GCC.args.extra.hpp_o = $$(GCC.args.extra.hpp_o)
+ $(1).GCC.args.extra.cpp_o = $$(GCC.args.extra.cpp_o)
+ $(1).GCC.args.extra.dylib++ = $$(GCC.args.extra.dylib++)
+ $(1).GCC.args.extra.exe++ = $$(GCC.args.extra.exe++)
+
###########################################################################
$(1).GCC.c = -c $$(4)
$(1).GCC.o = -o $$(3)
# FUNCTION: C precompiled headers
- $(1).GCC.H_O.args = !gcc ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra *D *I !c !o
+ $(1).GCC.H_O.args = !gcc ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra ?extra.h_o *D *I !c !o
$(1).GCC.H_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.H_O.args),$$(1),$$(2))
# FUNCTION: C compile source
- $(1).GCC.C_O.args = !gcc ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra *D *I !c !o
+ $(1).GCC.C_O.args = !gcc ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra ?extra.c_o *D *I !c !o
$(1).GCC.C_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.C_O.args),$$(1),$$(2))
# FUNCTION: C++ precompile headers
- $(1).GCC.HPP_O.args = !gxx ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra *D *I !c !o
+ $(1).GCC.HPP_O.args = !gxx ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra ?extra.hpp_o *D *I !c !o
$(1).GCC.HPP_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.HPP_O.args),$$(1),$$(2))
# FUNCTION: C++ compile source
- $(1).GCC.CPP_O.args = !gxx ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra *D *I !c !o
+ $(1).GCC.CPP_O.args = !gxx ?pipe ?ML ?H *W *archs ?vis ?pic .g .O ?extra ?extra.cpp_o *D *I !c !o
$(1).GCC.CPP_O = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.CPP_O.args),$$(1),$$(2))
###########################################################################
@@ -133,18 +169,18 @@ define import.GCC
$(1).GCC.i = $$(4)
# FUNCTION: C link dynamic-lib
- $(1).GCC.DYLIB.args = !gcc ?pipe ?strip ?dylib ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+ $(1).GCC.DYLIB.args = !gcc ?pipe ?strip ?dylib ?extra.dylib ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
$(1).GCC.DYLIB = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.DYLIB.args),$$(1),$$(2))
# FUNCTION: C link executable
- $(1).GCC.EXE.args = !gcc ?pipe ?strip ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+ $(1).GCC.EXE.args = !gcc ?pipe ?strip ?extra.exe ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
$(1).GCC.EXE = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.EXE.args),$$(1),$$(2))
# FUNCTION: C++ link dynamic-lib
- $(1).GCC.DYLIB++.args = !gxx ?pipe ?strip ?dylib ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+ $(1).GCC.DYLIB++.args = !gxx ?pipe ?strip ?dylib ?extra.dylib++ ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
$(1).GCC.DYLIB++ = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.DYLIB++.args),$$(1),$$(2))
# FUNCTION: C++ link executable
- $(1).GCC.EXE++.args = !gxx ?pipe ?strip ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
+ $(1).GCC.EXE++.args = !gxx ?pipe ?strip ?extra.exe++ ?ML *W *archs ?vis ?pic .g .O ?extra *D *I !o ?muldefs ?start !i *F *f *L *l *i !a ?end
$(1).GCC.EXE++ = $$(call fn.ARGS,$(1).GCC,$$($(1).GCC.EXE++.args),$$(1),$$(2))
endef
diff --git a/make/include/main.defs b/make/include/main.defs
index f07678b79..a1bafbb92 100644
--- a/make/include/main.defs
+++ b/make/include/main.defs
@@ -10,7 +10,7 @@ include $(SRC/)make/include/tool.defs
MODULES += contrib/a52dec
-ifneq (,$(filter $(BUILD.system),cygwin))
+ifneq (,$(filter $(BUILD.system),cygwin mingw))
MODULES += contrib/bzip2
endif
@@ -27,10 +27,15 @@ MODULES += contrib/libsamplerate
MODULES += contrib/libtheora
MODULES += contrib/libvorbis
MODULES += contrib/mpeg2dec
+
+ifneq (,$(filter $(BUILD.system),mingw))
+ MODULES += contrib/pthreadw32
+endif
+
MODULES += contrib/x264
MODULES += contrib/xvidcore
-ifneq (,$(filter $(BUILD.system),cygwin))
+ifneq (,$(filter $(BUILD.system),cygwin mingw))
MODULES += contrib/zlib
endif
@@ -39,21 +44,21 @@ MODULES += libhb
###############################################################################
-## test module is replaced with macosx when Darwin+Xcode
-ifneq (,$(filter $(BUILD.system),darwin))
- ifeq (1,$(FEATURE.xcode))
- MODULES += macosx
- else
- MODULES += test
- endif
+ifeq (1-darwin,$(FEATURE.xcode)-$(BUILD.system))
+ ## use macosx module when xcode+darwin
+ MODULES += macosx
else
+ ## default is to build CLI
MODULES += test
endif
-ifneq (,$(filter $(BUILD.system),linux))
- ifeq (1,$(FEATURE.gtk))
- MODULES += gtk
- endif
+ifeq (1-mingw,$(FEATURE.gtk.mingw)-$(BUILD.system))
+ MODULES += gtk
+endif
+
+ifeq (1-linux,$(FEATURE.gtk)-$(BUILD.system))
+ ## build gtk when gtk+linux
+ MODULES += gtk
endif
###############################################################################
@@ -63,5 +68,5 @@ MODULES += doc
###############################################################################
include $(MODULES:%=$(SRC/)%/module.defs)
-include $(SRC/)make/variant/$(HOST.system).defs
--include $(SRC/)make/variant/$(HOST.system).$(BUILD.machine).defs
+include $(SRC/)make/variant/$(BUILD.system).defs
+-include $(SRC/)make/variant/$(BUILD.system).$(BUILD.machine).defs
diff --git a/make/include/main.rules b/make/include/main.rules
index d1a16212a..2b288ab31 100644
--- a/make/include/main.rules
+++ b/make/include/main.rules
@@ -33,8 +33,8 @@ mrproper: xclean
include $(SRC/)make/include/base.rules
include $(MODULES:%=$(SRC/)%/module.rules)
--include $(SRC/)make/variant/$(HOST.system).rules
--include $(SRC/)make/variant/$(HOST.system).$(BUILD.machine).rules
+-include $(SRC/)make/variant/$(BUILD.system).rules
+-include $(SRC/)make/variant/$(BUILD.system).$(BUILD.machine).rules
###############################################################################
diff --git a/make/variant/mingw.defs b/make/variant/mingw.defs
new file mode 100644
index 000000000..81c2b043a
--- /dev/null
+++ b/make/variant/mingw.defs
@@ -0,0 +1,10 @@
+TARGET.exe.suffix = .exe
+
+GCC.start = 1
+GCC.end = 1
+
+GCC.args.dylib = -shared
+GCC.args.g.none = -g0
+GCC.args.g.min = -g1
+GCC.args.g.default = -g2
+GCC.args.g.max = -g3
diff --git a/test/module.defs b/test/module.defs
index 234cb1dcf..0859ddefd 100644
--- a/test/module.defs
+++ b/test/module.defs
@@ -16,7 +16,6 @@ TEST.libs = $(LIBHB.a) $(foreach n, \
TEST.install.exe = $(PREFIX/)bin/$(notdir $(TEST.exe))
-## add libs from optional modules
ifeq (1,$(BZIP2.enabled))
TEST.libs += $(CONTRIB.build/)lib/libbz2.a
endif
@@ -41,4 +40,8 @@ ifeq ($(BUILD.system),darwin)
TEST.GCC.l += bz2 z
else ifeq ($(BUILD.system),linux)
TEST.GCC.l += bz2 z pthread dl m
+else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system))
+ TEST.libs += $(CONTRIB.build/)lib/libpthreadGC2.a
+ TEST.GCC.D += PTW32_STATIC_LIB
+ TEST.GCC.l += iberty ws2_32
endif
diff --git a/test/test.c b/test/test.c
index 7b4c67899..3273c5716 100644
--- a/test/test.c
+++ b/test/test.c
@@ -154,6 +154,11 @@ int main( int argc, char ** argv )
return 1;
}
+#ifdef PTW32_STATIC_LIB
+ pthread_win32_process_attach_np();
+ pthread_win32_thread_attach_np();
+#endif
+
/* Register our error handler */
hb_register_error_handler(&hb_cli_error_handler);
@@ -210,7 +215,7 @@ int main( int argc, char ** argv )
/* Wait... */
while( !die )
{
-#if !defined(SYS_BEOS)
+#if !defined(SYS_BEOS) && !defined(__MINGW32__)
fd_set fds;
struct timeval tv;
int ret;
@@ -299,6 +304,11 @@ int main( int argc, char ** argv )
fprintf( stderr, "HandBrake has exited.\n" );
+#ifdef PTW32_STATIC_LIB
+ pthread_win32_thread_detach_np();
+ pthread_win32_process_detach_np();
+#endif
+
return 0;
}