diff options
author | jstebbins <[email protected]> | 2010-05-23 15:38:21 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-05-23 15:38:21 +0000 |
commit | 28658486daa5cd3e7a58edb3539885422889c44f (patch) | |
tree | 22bd3d2a80d5443584ece6d769cd7d41c53cdfaa | |
parent | a28717d0b3d41674934d6e0e24ee70344576fb1e (diff) |
add ability to probe for existance of headers and libraries to configure.py
use this to check for system versions of bz2 z pthreadGC2 iberty and dl when
building with mingw. solves a problem with conflicts when building on fedora with
a full standard install of their mingw packages.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3316 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | gtk/configure.ac | 12 | ||||
-rw-r--r-- | gtk/module.defs | 7 | ||||
-rw-r--r-- | gtk/module.rules | 11 | ||||
-rw-r--r-- | libhb/module.defs | 31 | ||||
-rw-r--r-- | make/configure.py | 172 | ||||
-rw-r--r-- | make/include/main.defs | 8 | ||||
-rw-r--r-- | test/module.defs | 23 |
7 files changed, 248 insertions, 16 deletions
diff --git a/gtk/configure.ac b/gtk/configure.ac index 0323214f2..423923bf4 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -45,6 +45,10 @@ else AC_SUBST(HB_DIR, '$(top_srcdir)/'"..") fi +AC_ARG_ENABLE(dl, + AS_HELP_STRING([--enable-dl], [enable libdl]), + use_libdl=yes, use_libdl=no) + AC_ARG_ENABLE(gst, AS_HELP_STRING([--enable-gst], [enable gstreamer on Win32]), w32_gst=yes, w32_gst=no) @@ -103,6 +107,14 @@ AM_CONDITIONAL([MINGW], [test "x$mingw_flag" = "xyes"]) PKG_CHECK_MODULES(GHB, [$GHB_PACKAGES]) +case $host in + *-*-mingw*) + if test "x$use_libdl" = "xyes" ; then + GHB_LIBS="$GHB_LIBS -ldl" + fi + ;; +esac + AC_SUBST(GHB_CFLAGS) AC_SUBST(GHB_LIBS) diff --git a/gtk/module.defs b/gtk/module.defs index 8c1648d61..6801d61aa 100644 --- a/gtk/module.defs +++ b/gtk/module.defs @@ -6,6 +6,13 @@ GTK.build/ = $(BUILD/)gtk/ GTK.CONFIGURE.stamp = $(GTK.build/).stamp.configure +ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system)) +GTK.CONFIGURE.extra += --host=$(BUILD.spec) +ifeq ($(HAS.dlfcn),1) + GTK.CONFIGURE.extra += --enable-dl +endif +endif + ############################################################################### GTK.out += $(GTK.CONFIGURE.stamp) diff --git a/gtk/module.rules b/gtk/module.rules index e7d93e752..138fe64a6 100644 --- a/gtk/module.rules +++ b/gtk/module.rules @@ -13,22 +13,13 @@ $(GTK.CONFIGURE.stamp): | $(dir $(GTK.CONFIGURE.stamp)) $(GTK.CONFIGURE.stamp): $(GTK.src/)Makefile.am $(GTK.CONFIGURE.stamp): $(GTK.src/)configure.ac $(GTK.src/)src/Makefile.am set -e; cd $(GTK.src/); NOCONFIGURE=1 ./autogen.sh -ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system)) set -e; cd $(GTK.build/); $(call fn.ABSOLUTE,$(GTK.src/))configure \ - --host=$(BUILD.spec) \ + $(GTK.CONFIGURE.extra) \ PKG_CONFIG_PATH=$(BUILD/)contrib/lib/pkgconfig \ CFLAGS="$(call fn.ARGS,GTK.GCC,.g .O *D ?extra)" \ LDFLAGS="$(call fn.ARGS,GTK.GCC,?strip .g .O) " \ --prefix=$(PREFIX) \ --with-hb=$(call fn.ABSOLUTE,$(BUILD/)) -else - set -e; cd $(GTK.build/); $(call fn.ABSOLUTE,$(GTK.src/))configure \ - PKG_CONFIG_PATH=$(BUILD/)contrib/lib/pkgconfig \ - CFLAGS="$(call fn.ARGS,GTK.GCC,.g .O ?extra)" \ - LDFLAGS="$(call fn.ARGS,GTK.GCC,?strip .g .O)" \ - --prefix=$(PREFIX) \ - --with-hb=$(call fn.ABSOLUTE,$(BUILD/)) -endif $(TOUCH.exe) $@ gtk.build: | $(GTK.build/) diff --git a/libhb/module.defs b/libhb/module.defs index e73102c9a..36397e61d 100644 --- a/libhb/module.defs +++ b/libhb/module.defs @@ -89,12 +89,39 @@ LIBHB.dll = $(LIBHB.build/)hb.dll LIBHB.lib = $(LIBHB.build/)hb.lib LIBHB.dll.libs = $(foreach n, \ - a52 bz2 avcodec avformat avutil dca dvdnav dvdread faac faad iconv mkv mpeg2 mp3lame mp4v2 \ - ogg pthreadGC2 samplerate swscale theora vorbis vorbisenc x264 z, \ + a52 avcodec avformat avutil dca dvdnav dvdread faac faad mkv mpeg2 mp3lame mp4v2 \ + ogg samplerate swscale theora vorbis vorbisenc x264, \ $(CONTRIB.build/)lib/lib$(n).a ) +ifneq ($(HAS.iconv),1) +LIBHB.dll.libs += $(CONTRIB.build/)lib/libiconv.a +else + LIBHB.GCC.l += iconv +endif + +ifneq ($(HAS.pthread),1) +LIBHB.dll.libs += $(CONTRIB.build/)lib/libpthreadGC2.a +else + LIBHB.GCC.l += pthreadGC2 +endif + +ifneq ($(HAS.bz2),1) +LIBHB.dll.libs += $(CONTRIB.build/)lib/libbz2.a +else + LIBHB.GCC.l += bz2 +endif + +ifneq ($(HAS.libz),1) +LIBHB.dll.libs += $(CONTRIB.build/)lib/libz.a +else + LIBHB.GCC.l += z +endif + LIBHB.GCC.args.extra.dylib++ += -Wl,--out-implib,$(LIBHB.lib) LIBHB.GCC.l += iberty ws2_32 +ifeq ($(HAS.dlfcn),1) + LIBHB.GCC.l += dl +endif LIBHB.out += $(LIBHB.dll) $(LIBHB.lib) endif diff --git a/make/configure.py b/make/configure.py index 27c38014e..dcd798cf4 100644 --- a/make/configure.py +++ b/make/configure.py @@ -314,6 +314,90 @@ class ShellProbe( Action ): ############################################################################### ## +## Compile test probe: determine if compile time feature is supported +## +## returns true if feature successfully compiles +## +## +class CCProbe( Action ): + def __init__( self, pretext, command, test_file ): + super( CCProbe, self ).__init__( 'probe', pretext ) + self.command = command + self.test_file = test_file + + def _action( self ): + ## write program file + file = open( 'conftest.c', 'w' ) + file.write( self.test_file ) + file.close() + ## pipe and redirect stderr to stdout; effects communicate result + pipe = subprocess.Popen( '%s -c -o conftest.o conftest.c' % self.command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) + + ## read data into memory buffers, only first element (stdout) data is used + data = pipe.communicate() + self.fail = pipe.returncode != 0 + + if data[0]: + self.session = data[0].splitlines() + else: + self.session = [] + + if pipe.returncode: + self.msg_end = 'code %d' % (pipe.returncode) + os.remove( 'conftest.c' ) + if not self.fail: + os.remove( 'conftest.o' ) + + def _dumpSession( self, printf ): + printf( ' + %s\n', self.command ) + super( CCProbe, self )._dumpSession( printf ) + + +############################################################################### +## +## Compile test probe: determine if compile time feature is supported +## +## returns true if feature successfully compiles +## +## +class LDProbe( Action ): + def __init__( self, pretext, command, lib, test_file ): + super( LDProbe, self ).__init__( 'probe', pretext ) + self.command = command + self.test_file = test_file + self.lib = lib + + def _action( self ): + ## write program file + file = open( 'conftest.c', 'w' ) + file.write( self.test_file ) + file.close() + ## pipe and redirect stderr to stdout; effects communicate result + pipe = subprocess.Popen( '%s -o conftest conftest.c %s' % (self.command, self.lib), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT ) + + ## read data into memory buffers, only first element (stdout) data is used + data = pipe.communicate() + self.fail = pipe.returncode != 0 + + if data[0]: + self.session = data[0].splitlines() + else: + self.session = [] + + if pipe.returncode: + self.msg_end = 'code %d' % (pipe.returncode) + + os.remove( 'conftest.c' ) + if not self.fail: + os.remove( 'conftest' ) + + def _dumpSession( self, printf ): + printf( ' + %s\n', self.command ) + super( LDProbe, self )._dumpSession( printf ) + + +############################################################################### +## ## GNU host tuple probe: determine canonical platform type ## ## example results from various platforms: @@ -1200,6 +1284,81 @@ try: for action in Action.actions: action.run() + if build.system == 'mingw': + dlfcn_test = """ +#include <dlfcn.h> +#include <stdio.h> + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, RTLD_GLOBAL|RTLD_NOW); + int status = 1; + + if (self) + { + if (dlsym (self,"fnord")) status = 0; + else if (dlsym( self,"_fnord")) status = 0; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +} +""" + dlfcn = LDProbe( 'static dlfcn', '%s -static' % Tools.gcc.pathname, '-ldl', dlfcn_test ) + dlfcn.run() + + pthread_test = """ +#include <stdio.h> +#include <pthread.h> +int main () +{ + pthread_t thread; + pthread_create (&thread, NULL, NULL, NULL); + return 0; +} +""" + pthread = LDProbe( 'static pthread', '%s -static' % Tools.gcc.pathname, '-lpthreadGC2', pthread_test ) + pthread.run() + + bz2_test = """ +#include <stdio.h> +#include <bzlib.h> +int main () +{ + BZ2_bzReadOpen(NULL, NULL, 0, 0, NULL, 0); + return 0; +} +""" + bz2 = LDProbe( 'static bz2', '%s -static' % Tools.gcc.pathname, '-lbz2', bz2_test ) + bz2.run() + + libz_test = """ +#include <stdio.h> +#include <zlib.h> +int main () +{ + compress(NULL, NULL, NULL, 0); + return 0; +} +""" + libz = LDProbe( 'static zlib', '%s -static' % Tools.gcc.pathname, '-lz', libz_test ) + libz.run() + + iconv_test = """ +#include <stdio.h> +#include <iconv.h> +int main () +{ + iconv_open(NULL, NULL); + return 0; +} +""" + iconv = LDProbe( 'static iconv', '%s -static' % Tools.gcc.pathname, '-liconv', iconv_test ) + iconv.run() + ## cfg hook before doc prep cfg.doc_ready() @@ -1301,6 +1460,19 @@ try: doc.add( 'XCODE.external.build', cfg.xcode_x_build ) doc.add( 'XCODE.external.prefix', cfg.xcode_x_prefix ) + doc.addBlank() + if build.system == 'mingw': + if not dlfcn.fail: + doc.add( 'HAS.dlfcn', 1 ) + if not pthread.fail: + doc.add( 'HAS.pthread', 1 ) + if not bz2.fail: + doc.add( 'HAS.bz2', 1 ) + if not libz.fail: + doc.add( 'HAS.libz', 1 ) + if not iconv.fail: + doc.add( 'HAS.iconv', 1 ) + doc.addMake( '' ) doc.addMake( '## define debug mode before other includes' ) doc.addMake( '## since it is tested in some module.defs' ) diff --git a/make/include/main.defs b/make/include/main.defs index 3228593ba..23c176fd9 100644 --- a/make/include/main.defs +++ b/make/include/main.defs @@ -11,8 +11,10 @@ include $(SRC/)make/include/tool.defs MODULES += contrib/a52dec ifneq (,$(filter $(BUILD.system),cygwin mingw)) +ifneq ($(HAS.bz2),1) MODULES += contrib/bzip2 endif +endif MODULES += contrib/faac MODULES += contrib/faad2 @@ -30,15 +32,21 @@ MODULES += contrib/mp4v2 MODULES += contrib/mpeg2dec ifneq (,$(filter $(BUILD.system),mingw)) +ifneq ($(HAS.pthread),1) MODULES += contrib/pthreadw32 endif +endif MODULES += contrib/x264 ifneq (,$(filter $(BUILD.system),cygwin mingw)) +ifneq ($(HAS.iconv),1) MODULES += contrib/libiconv +endif +ifneq ($(HAS.libz),1) MODULES += contrib/zlib endif +endif ifneq (,$(filter $(BUILD.system),solaris)) MODULES += contrib/libiconv diff --git a/test/module.defs b/test/module.defs index d703d179f..6fb748e12 100644 --- a/test/module.defs +++ b/test/module.defs @@ -16,14 +16,21 @@ TEST.libs = $(LIBHB.a) $(foreach n, \ TEST.install.exe = $(DESTDIR)$(PREFIX/)bin/$(notdir $(TEST.exe)) +ifeq (1,$(PTHREADW32.enabled)) + TEST.libs += $(CONTRIB.build/)lib/libpthreadGC2.a +endif ifeq (1,$(LIBICONV.enabled)) TEST.libs += $(CONTRIB.build/)lib/libiconv.a endif ifeq (1,$(BZIP2.enabled)) TEST.libs += $(CONTRIB.build/)lib/libbz2.a +else + TEST.GCC.l += bz2 endif ifeq (1,$(ZLIB.enabled)) TEST.libs += $(CONTRIB.build/)lib/libz.a +else + TEST.GCC.l += z endif ############################################################################### @@ -40,13 +47,21 @@ TEST.GCC.I += $(LIBHB.GCC.I) ifeq ($(BUILD.system),darwin) TEST.GCC.f += IOKit CoreServices AudioToolbox - TEST.GCC.l += iconv bz2 z + TEST.GCC.l += iconv else ifeq ($(BUILD.system),linux) - TEST.GCC.l += bz2 z pthread dl m + TEST.GCC.l += pthread dl m else ifeq ($(BUILD.system),solaris) - TEST.GCC.l += bz2 z pthread nsl socket + TEST.GCC.l += pthread nsl socket else ifeq (1-mingw,$(BUILD.cross)-$(BUILD.system)) - TEST.libs += $(CONTRIB.build/)lib/libpthreadGC2.a +ifeq ($(HAS.iconv),1) + TEST.GCC.l += iconv +endif +ifeq ($(HAS.pthread),1) + TEST.GCC.l += pthreadGC2 +endif +ifeq ($(HAS.dlfcn),1) + TEST.GCC.l += dl +endif TEST.GCC.D += PTW32_STATIC_LIB TEST.GCC.l += iberty ws2_32 TEST.GCC.args.extra.exe++ += -static |