summaryrefslogtreecommitdiffstats
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rw-r--r--make/configure.py150
1 files changed, 74 insertions, 76 deletions
diff --git a/make/configure.py b/make/configure.py
index c0a6f7662..b4f891a14 100644
--- a/make/configure.py
+++ b/make/configure.py
@@ -364,6 +364,34 @@ class CCProbe( Action ):
## returns true if feature successfully compiles
##
##
+def PkgConfigTest(args, lib):
+ msg_end = ''
+ if Tools.pkgconfig.fail:
+ fail = True
+ session = []
+ msg_end = 'No pkg-config'
+ return fail, msg_end, session
+
+ ## pipe and redirect stderr to stdout; effects communicate result
+ pipe = subprocess.Popen( '%s %s %s' %
+ (Tools.pkgconfig.pathname, args, lib),
+ shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
+
+ ## read data into memory buffers, only first element (stdout)
+ ## data is used
+ data = pipe.communicate()
+ fail = pipe.returncode != 0
+
+ if data[0]:
+ session = data[0].splitlines()
+ else:
+ session = []
+
+ if pipe.returncode:
+ msg_end = 'code %d' % (pipe.returncode)
+
+ return fail, msg_end, session
+
class PkgConfigProbe( Action ):
def __init__( self, pretext, args, lib ):
super( PkgConfigProbe, self ).__init__( 'probe', pretext )
@@ -371,29 +399,8 @@ class PkgConfigProbe( Action ):
self.lib = lib
def _action( self ):
- if Tools.pkgconfig.fail:
- self.fail = True
- self.session = []
- self.msg_end = 'No pkg-config'
- return
-
- ## pipe and redirect stderr to stdout; effects communicate result
- pipe = subprocess.Popen( '%s %s %s' %
- (Tools.pkgconfig.pathname, self.args, 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)
+ self.fail, self.msg_end, self.session = PkgConfigTest(self.args,
+ self.lib)
def _dumpSession( self, printf ):
printf( ' + %s %s\n', Tools.pkgconfig.pathname, self.args )
@@ -407,6 +414,38 @@ class PkgConfigProbe( Action ):
## returns true if feature successfully compiles
##
##
+def LDTest(command, lib, test_file):
+ ## write program file
+ with open( 'conftest.c', 'w' ) as out_file:
+ out_file.write( test_file )
+ ## pipe and redirect stderr to stdout; effects communicate result
+ pipe = subprocess.Popen( '%s -o conftest conftest.c %s' % (command, lib), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
+
+ ## read data into memory buffers, only first element (stdout) data is used
+ data = pipe.communicate()
+ fail = pipe.returncode != 0
+
+ if data[0]:
+ session = data[0].splitlines()
+ else:
+ session = []
+
+ msg_end = ''
+ if pipe.returncode:
+ msg_end = 'code %d' % (pipe.returncode)
+
+ os.remove( 'conftest.c' )
+ if not fail:
+ try:
+ os.remove( 'conftest.exe' )
+ except:
+ pass
+ try:
+ os.remove( 'conftest' )
+ except:
+ pass
+ return (fail, msg_end, session)
+
class LDProbe( Action ):
def __init__( self, pretext, command, lib, test_file ):
super( LDProbe, self ).__init__( 'probe', pretext )
@@ -415,34 +454,8 @@ class LDProbe( Action ):
self.lib = lib
def _action( self ):
- ## write program file
- with open( 'conftest.c', 'w' ) as out_file:
- out_file.write( self.test_file )
- ## 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:
- try:
- os.remove( 'conftest.exe' )
- except:
- pass
- try:
- os.remove( 'conftest' )
- except:
- pass
+ self.fail, self.msg_end, self.session = LDTest(
+ self.command, self.lib, self.test_file)
def _dumpSession( self, printf ):
printf( ' + %s\n', self.command )
@@ -457,8 +470,8 @@ class LDProbe( Action ):
##
##
class ChkLib( Action ):
- def __init__( self, pretext, command, lib, test_file ):
- super( ChkLib, self ).__init__( 'probe', pretext )
+ def __init__( self, pretext, command, lib, test_file, abort=False ):
+ super( ChkLib, self ).__init__( 'probe', pretext, abort=abort )
self.command = command
self.test_file = test_file
self.lib = lib
@@ -466,28 +479,15 @@ class ChkLib( Action ):
def _action( self ):
## First try pkg-config
if not Tools.pkgconfig.fail:
- pkgconfig = PkgConfigProbe( 'pkgconfig %s' % self.pretext,
- '--libs', self.lib )
- pkgconfig.run()
- if not pkgconfig.fail:
- self.session = pkgconfig.session
- self.fail = False
+ self.fail, self.msg_end, self.session = PkgConfigTest(
+ '--libs', self.lib)
+ if not self.fail:
return
- ld = LDProbe( 'link %s' % self.pretext, self.command,
- '-l%s' % self.lib, self.test_file )
- ld.run()
- self.session = ld.session
- self.fail = ld.fail
- if self.fail:
- self.msg_end = ld.msg_end
-
- def _actionEnd( self ):
- pass
-
- def _dumpSession( self, printf ):
- printf( ' + %s\n', self.command )
- super( ChkLib, self )._dumpSession( printf )
+ ## If pkg-config fails, try compiling and linking test file
+ self.fail, self.msg_end, session = LDTest(
+ self.command, '-l%s' % self.lib, self.test_file)
+ self.session.append(session)
###############################################################################
##
@@ -1850,11 +1850,9 @@ return 0;
"""
numa = ChkLib( 'numa', '%s' % Tools.gcc.pathname,
- 'numa', numa_test )
+ 'numa', numa_test, abort=True )
numa.run()
- if numa.fail:
- cfg.errln( 'Failed to find libnuma' )
## cfg hook before doc prep
cfg.doc_ready()