root/trunk/libffado/admin/pkgconfig.py

Revision 601, 1.8 kB (checked in by arnonym, 15 years ago)

Maybe this time the pkg-flags will get cached and pkg-config isn't called anymore during install / after the first time...

Line 
1 #!/usr/bin/python
2
3 #
4 # Taken from http://www.scons.org/wiki/UsingPkgConfig
5 #
6
7 #
8 # Checks for pkg-config
9 #
10 def CheckForPKGConfig( context, version='0.0.0' ):
11         context.Message( "Checking for pkg-config (at least version %s)... " % version )
12         ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
13         context.Result( ret )
14         return ret
15
16 #
17 # Checks for the given package with an optional version-requirement
18 #
19 # The flags (which can be imported into the environment by env.MergeFlags(...)
20 # are exported as env['NAME_FLAGS'] where name is built by removing all +,-,.
21 # and upper-casing.
22 #
23 def CheckForPKG( context, name, version="" ):
24         name2 = name.replace("+","").replace(".","").replace("-","")
25
26         if version == "":
27                 context.Message( "Checking for %s... \t" % name )
28                 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
29         else:
30                 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
31                 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
32
33         if ret:
34                 context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
35
36         context.Result( ret )
37         return ret
38
39 #
40 # Checks for the existance of the package and returns the packages flags.
41 #
42 # This should allow caching of the flags so that pkg-config is called only once.
43 #
44 def GetPKGFlags( context, name, version="" ):
45         import os
46
47         if version == "":
48                 context.Message( "Checking for %s... \t" % name )
49                 ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
50         else:
51                 context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
52                 ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
53
54         if not ret:
55                 context.Result( ret )
56                 return ret
57
58         out = os.popen2( "pkg-config --cflags --libs %s" % name )[1]
59         ret = out.read()
60
61         context.Result( True )
62         return ret
63
Note: See TracBrowser for help on using the browser.