config: Change pkgconfig to check.

Add the extra actions: ccflags, cflags, ldflags and libs to allow the
fetching of these from pkg-config files.
This commit is contained in:
Chris Johns 2014-02-11 14:06:45 +11:00
parent 55e52f403d
commit c5b5493c19
5 changed files with 53 additions and 10 deletions

View File

@ -13,6 +13,6 @@
#
# The GetText build instructions. We use 0.x.x Release 1.
#
%ifn %{pkgconfig gettext}
%ifn %{check gettext}
%include %{_configdir}/gettext-0-1.cfg
%endif

View File

@ -15,6 +15,6 @@
#
# The GLib build instructions. We use 2.x.x Release 1.
#
%ifn %{pkgconfig glib-2.0}
%ifn %{check glib-2.0}
%include %{_configdir}/glib-2-1.cfg
%endif

View File

@ -13,6 +13,6 @@
#
# The LibFFI build instructions. We use 3.x.x Release 1.
#
%ifn %{pkgconfig libffi}
%ifn %{check libffi}
%include %{_configdir}/libffi-3-1.cfg
%endif

View File

@ -13,6 +13,6 @@
#
# The Pixman build instructions. We use 0.x.x Release 1.
#
%ifn %{pkgconfig pixman-1}
%ifn %{check pixman-1}
%include %{_configdir}/pixman-0-1.cfg
%endif

View File

@ -368,12 +368,12 @@ class file:
raise error.general('shell macro failed: %s:%d: %s' % (s, exit_code, output))
return line
def _pkgconfig(self, test):
def _pkgconfig_check(self, test):
ts = test.split()
ok = False
pkg = pkgconfig.package(ts[0], output = log.output)
if len(ts) > 1 and len(ts) != 3:
self._error('malformed pkgconfig check')
if len(ts) != 1 and len(ts) != 3:
self._error('malformed check')
else:
op = '>='
ver = '0'
@ -383,11 +383,22 @@ class file:
try:
ok = pkg.check(op, ver)
except pkgconfig.error, pe:
self._error('pkgconfig: %s' % (pe))
self._error('check: %s' % (pe))
except:
raise error.interal('pkgconfig failure')
return ok
def _pkgconfig_flags(self, package, flags):
pkg_flags = None
pkg = pkgconfig.package(package, output = log.output)
try:
pkg_flags = pkg.get(flags)
except pkgconfig.error, pe:
self._error('flags:%s: %s' % (flags, pe))
except:
raise error.interal('pkgconfig failure')
return pkg_flags
def _expand(self, s):
expand_count = 0
expanded = True
@ -450,13 +461,45 @@ class file:
s = s.replace(m, '0')
expanded = True
mn = None
elif m.startswith('%{pkgconfig'):
if self._pkgconfig(m[11:-1].strip()):
elif m.startswith('%{check'):
if self._pkgconfig_check(m[7:-1].strip()):
s = s.replace(m, '1')
else:
s = s.replace(m, '0')
expanded = True
mn = None
elif m.startswith('%{ccflags'):
flags = self._pkgconfig_flags(m[9:-1].strip(), 'ccflags')
if flags:
s = s.replace(m, flags)
else:
self._error('ccflags error: %s' % (m[9:-1].strip()))
expanded = True
mn = None
elif m.startswith('%{cflags'):
flags = self._pkgconfig_flags(m[8:-1].strip(), 'cflags')
if flags:
s = s.replace(m, flags)
else:
self._error('cflags error: %s' % (m[8:-1].strip()))
expanded = True
mn = None
elif m.startswith('%{ldflags'):
flags = self._pkgconfig_flags(m[9:-1].strip(), 'ldflags')
if flags:
s = s.replace(m, flags)
else:
self._error('ldflags error: %s' % (m[9:-1].strip()))
expanded = True
mn = None
elif m.startswith('%{libs'):
flags = self._pkgconfig_flags(m[6:-1].strip(), 'libs')
if flags:
s = s.replace(m, flags)
else:
self._error('libs error: %s' % (m[6:-1].strip()))
expanded = True
mn = None
elif m.startswith('%{?') or m.startswith('%{!?'):
if m[2] == '!':
start = 4