root/trunk/libffado/admin/pkgconfig.py

Revision 742, 2.8 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

Line 
1 #!/usr/bin/python
2 #
3 # Copyright (C) 2007 Arnold Krille
4 #
5 # This file is part of FFADO
6 # FFADO = Free Firewire (pro-)audio drivers for linux
7 #
8 # FFADO is based upon FreeBoB.
9 #
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 3 of the License, or
13 # (at your option) any later version.
14 #
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.
19 #
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/>.
22 #
23
24 #
25 # Taken from http://www.scons.org/wiki/UsingPkgConfig
26 # and heavily modified
27 #
28
29 #
30 # Checks for pkg-config
31 #
32 def CheckForPKGConfig( context, version='0.0.0' ):
33         context.Message( "Checking for pkg-config (at least version %s)... " % version )
34         ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
35         context.Result( ret )
36         return ret
37
38 #
39 # Checks for the given package with an optional version-requirement
40 #
41 # The flags (which can be imported into the environment by env.MergeFlags(...)
42 # are exported as env['NAME_FLAGS'] where name is built by removing all +,-,.
43 # and upper-casing.
44 #
45 def CheckForPKG( context, name, version="" ):
46         name2 = name.replace("+","").replace(".","").replace("-","")
47
48         if version == "":
49                 context.Message( "Checking for %s... \t" % name )
50                 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
51         else:
52                 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
53                 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
54
55         if ret:
56                 context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
57
58         context.Result( ret )
59         return ret
60
61 #
62 # Checks for the existance of the package and returns the packages flags.
63 #
64 # This should allow caching of the flags so that pkg-config is called only once.
65 #
66 def GetPKGFlags( context, name, version="" ):
67         import os
68
69         if version == "":
70                 context.Message( "Checking for %s... \t" % name )
71                 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
72         else:
73                 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
74                 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
75
76         if not ret:
77                 context.Result( ret )
78                 return ret
79
80         out = os.popen2( "pkg-config --cflags --libs %s" % name )[1]
81         ret = out.read()
82
83         context.Result( True )
84         return ret
85
86 def generate( env, **kw ):
87         env['PKGCONFIG_TESTS' ] = { 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags }
88
89 def exists( env ):
90         return 1
91
92
Note: See TracBrowser for help on using the browser.