+## 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 )
+
+
+###############################################################################
+##