summaryrefslogtreecommitdiff
path: root/media-libs/libffado/files/libffado-2.5.0-fix_pkgconfig.patch
blob: 981555fa847df4ac1e46e0e811d53190b3cd0074 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
first try PKG_CONFIG instead of hardcoded pkg-config
see https://bugs.gentoo.org/791724
--- a/SConstruct
+++ b/SConstruct
@@ -198,7 +198,7 @@ int main() {
 
 def CheckPKG(context, name):
     context.Message( 'Checking for %s... ' % name )
-    ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
+    ret = context.TryAction("%s --exists '%s'" % (context.env['PKG_CONFIG'], name))[0]
     context.Result( ret )
     return ret
 
--- a/admin/pkgconfig.py
+++ b/admin/pkgconfig.py
@@ -26,6 +26,7 @@
 # and heavily modified
 #
 
+import os
 import subprocess
 
 #
@@ -33,7 +34,7 @@ import subprocess
 #
 def CheckForPKGConfig( context, version='0.0.0' ):
 	context.Message( "Checking for pkg-config (at least version %s)... " % version )
-	ret = context.TryAction( "pkg-config --atleast-pkgconfig-version=%s" %version )[0]
+	ret = context.TryAction( "%s --atleast-pkgconfig-version=%s" % (context.env['PKG_CONFIG'], version) )[0]
 	context.Result( ret )
 	return ret
 
@@ -49,13 +50,13 @@ def CheckForPKG( context, name, version="" ):
 
 	if version == "":
 		context.Message( "Checking for %s... \t" % name )
-		ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
+		ret = context.TryAction( "%s --exists '%s'" % (context.env['PKG_CONFIG'], name) )[0]
 	else:
 		context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
-		ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
+		ret = context.TryAction( "%s --atleast-version=%s '%s'" % (context.env['PKG_CONFIG'], version, name) )[0]
 
 	if ret:
-		context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!pkg-config --cflags --libs %s" % name)
+		context.env['%s_FLAGS' % name2.upper()] = context.env.ParseFlags("!%s --cflags --libs %s" % (context.env['PKG_CONFIG'], name))
 
 	context.Result( ret )
 	return ret
@@ -66,20 +67,18 @@ def CheckForPKG( context, name, version="" ):
 # This should allow caching of the flags so that pkg-config is called only once.
 #
 def GetPKGFlags( context, name, version="" ):
-	import os
-
 	if version == "":
 		context.Message( "Checking for %s... \t" % name )
-		ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
+		ret = context.TryAction( "%s --exists '%s'" % (context.env['PKG_CONFIG'], name) )[0]
 	else:
 		context.Message( "Checking for %s (%s or higher)... \t" % (name,version) )
-		ret = context.TryAction( "pkg-config --atleast-version=%s '%s'" % (version,name) )[0]
+		ret = context.TryAction( "%s --atleast-version=%s '%s'" % (context.env['PKG_CONFIG'], version, name) )[0]
 
 	if not ret:
 		context.Result( ret )
 		return ret
 
-	out = subprocess.Popen(['pkg-config', '--cflags', '--libs', name], stdout=subprocess.PIPE)
+	out = subprocess.Popen([context.env['PKG_CONFIG'], '--cflags', '--libs', name], stdout=subprocess.PIPE)
 	ret = out.stdout.read()
 
 	context.Result( True )
@@ -89,23 +88,22 @@ def GetPKGFlags( context, name, version="" ):
 # Checks for the existance of the package and returns the value of the specified variable.
 #
 def GetPKGVariable( context, name, variable ):
-	import os
-
 	context.Message( "Checking for variable %s in package %s... \t" % (variable,name) )
 
-	ret = context.TryAction( "pkg-config --exists '%s'" % name )[0]
+	ret = context.TryAction( "%s --exists '%s'" % (context.env['PKG_CONFIG'], name) )[0]
 	if not ret:
 		context.Result( ret )
 		return ret
 
-	out = subprocess.Popen(['pkg-config', '--variable=%s' % variable, name], stdout=subprocess.PIPE)
+	out = subprocess.Popen([context.env['PKG_CONFIG'], '--variable=%s' % variable, name], stdout=subprocess.PIPE)
 	ret = out.stdout.read()
 
 	context.Result( True )
 	return ret
 
 def generate( env, **kw ):
-	env['PKGCONFIG_TESTS' ] = { 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags, 'GetPKGVariable' : GetPKGVariable }
+       env.setdefault('PKG_CONFIG', os.environ.get('PKG_CONFIG', 'pkg-config'))
+       env['PKGCONFIG_TESTS' ] = { 'CheckForPKGConfig' : CheckForPKGConfig, 'CheckForPKG' : CheckForPKG, 'GetPKGFlags' : GetPKGFlags, 'GetPKGVariable' : GetPKGVariable }
 
 def exists( env ):
 	return 1
--- a/support/tools/ffado-diag.in
+++ b/support/tools/ffado-diag.in
@@ -22,7 +22,7 @@ static_info = "$LIBDATADIR/static_info.txt"
 # Test for common FFADO problems
 
 import glob
-import os.path
+import os
 import re
 import subprocess
 import sys
@@ -96,7 +96,7 @@ if path:
     version = version.decode ("utf8")
     show_pair ('', version [:version.find ("\n")])
 
-pkg_config = which ("pkg-config")
+pkg_config = os.environ.get("PKG_CONFIG") or which("pkg-config")
 show_pair ("pkg-config", pkg_config)
 
 if pkg_config: