Clean up compiler warnings when compiling on 64-bit systems. These are mostly fixing...
[ffado.git] / libffado / admin / pkgconfig.py
blobfc6d73a0ca01aa6802b3e5315d8262360adb2f35
1 #!/usr/bin/python
3 # Copyright (C) 2007-2008 Arnold Krille
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
8 # FFADO is based upon FreeBoB.
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 2 of the License, or
13 # (at your option) version 3 of the License.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 # Taken from http://www.scons.org/wiki/UsingPkgConfig
26 # and heavily modified
29 import subprocess
32 # Checks for pkg-config
34 def CheckForPKGConfig( context, version='0.0.0' ):
35 context.Message( "Checking for pkg-config (at least version %s)... " % version )
36 ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
37 context.Result( ret )
38 return ret
41 # Checks for the given package with an optional version-requirement
43 # The flags (which can be imported into the environment by env.MergeFlags(...)
44 # are exported as env['NAME_FLAGS'] where name is built by removing all +,-,.
45 # and upper-casing.
47 def CheckForPKG( context, name, version="" ):
48 name2 = name.replace("+","").replace(".","").replace("-","")
50 if version == "":
51 context.Message( "Checking for %s... \t" % name )
52 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
53 else:
54 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
55 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
57 if ret:
58 context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
60 context.Result( ret )
61 return ret
64 # Checks for the existance of the package and returns the packages flags.
66 # This should allow caching of the flags so that pkg-config is called only once.
68 def GetPKGFlags( context, name, version="" ):
69 import os
71 if version == "":
72 context.Message( "Checking for %s... \t" % name )
73 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
74 else:
75 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
76 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
78 if not ret:
79 context.Result( ret )
80 return ret
82 out = subprocess.Popen(['pkg-config', '--cflags', '--libs', name], stdout=subprocess.PIPE)
83 ret = out.stdout.read()
85 context.Result( True )
86 return ret
89 # Checks for the existance of the package and returns the value of the specified variable.
91 def GetPKGVariable( context, name, variable ):
92 import os
94 context.Message( "Checking for variable %s in package %s... \t" % (variable,name) )
96 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
97 if not ret:
98 context.Result( ret )
99 return ret
101 out = subprocess.Popen(['pkg-config', '--variable=%s' % variable, name], stdout=subprocess.PIPE)
102 ret = out.stdout.read()
104 context.Result( True )
105 return ret
107 def generate( env, **kw ):
108 env['PKGCONFIG_TESTS' ] = { 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags, 'GetPKGVariable' : GetPKGVariable }
110 def exists( env ):
111 return 1