X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bindings%2Fpython%2Fsetup.py;h=018e0809e03f72efc10a3cc557da36fb356ebad2;hb=9706bc1b42009a7c777dbe1d32027dea40f6c848;hp=60a358bf58890560fe437767e15627912b616069;hpb=7b89d13c0ef3a66054f1e61db7ddf243fddebccd;p=vlc diff --git a/bindings/python/setup.py b/bindings/python/setup.py index 60a358bf58..018e0809e0 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -2,24 +2,27 @@ from distutils.core import setup, Extension import os # Get build variables (buildir, srcdir) -try: - top_builddir=os.environ['top_builddir'] -except KeyError: - # Note: do not initialize here, so that we get - # a correct default value if the env. var is - # defined but empty - top_builddir=None -if not top_builddir: - top_builddir = os.path.join( '..', '..' ) - os.environ['top_builddir'] = top_builddir - -try: - srcdir=os.environ['srcdir'] -except KeyError: - # Note: same as above - srcdir=None -if not srcdir: - srcdir = '.' +top_builddir = os.path.join( '..', '..' ) +os.environ['top_builddir'] = top_builddir + +# Determine the extra link args. Normally, vlc-config should take care +# of this and return the right path values, from a development tree or +# an installed version. +libtool=False +linkargs=[] +d=os.path.join(top_builddir, 'src', '.libs') +if os.path.exists(d): + # We are in a development tree, which was compiled with libtool + libtool=True + linkargs=[ '-L' + d ] +else: + d=os.path.join(top_builddir, 'src') + # We are in a development tree, which was compiled without libtool + if os.path.exists(d): + linkargs=[ '-L' + d ] + +# For out-of-tree compilations +srcdir = '.' def get_vlcconfig(): vlcconfig=None @@ -54,15 +57,19 @@ def get_cflags(): def get_ldflags(): vlcconfig=get_vlcconfig() if vlcconfig is None: - return [] + return [ '-lvlc' ] else: ldflags = [] if os.sys.platform == 'darwin': ldflags = "-read_only_relocs warning".split() - ldflags.extend(os.popen('%s --libs vlc external' % vlcconfig, + ldflags.extend(os.popen('%s --libs external' % vlcconfig, 'r').readline().rstrip().split()) if os.sys.platform == 'darwin': ldflags.append('-lstdc++') + if not libtool: + # vlc-config is broken and gives a -lvlc which + # does not exist if libtool is disabled. + ldflags.remove('-lvlc') return ldflags #source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c', @@ -71,14 +78,14 @@ source_files = [ 'vlc_module.c' ] # To compile in a local vlc tree vlclocal = Extension('vlc', - sources = [ os.path.join( srcdir, f ) for f in source_files ], - include_dirs = [ top_builddir, - os.path.join( srcdir, '..', '..', 'include' ), - srcdir, - '/usr/win32/include' ], - extra_objects = [ ], + sources = [ os.path.join( srcdir, f ) for f in source_files ], + include_dirs = [ top_builddir, + os.path.join( srcdir, '..', '..', 'include' ), + srcdir, + '/usr/win32/include' ], + extra_objects = [ ], extra_compile_args = get_cflags(), - extra_link_args = [ '-L' + os.path.join(top_builddir, 'src', '.libs') ] + get_ldflags(), + extra_link_args = linkargs + get_ldflags(), ) setup (name = 'VLC Bindings',