Differences between revisions 23 and 24
Revision 23 as of 2008-03-12 02:47:05
Size: 1865
Editor: localhost
Comment: converted to 1.6 markup
Revision 24 as of 2013-04-03 15:04:16
Size: 1865
Editor: JoelAlmeida
Comment: lowercase in gtk+-2.0
Deletions are marked like this. Additions are marked like this.
Line 55: Line 55:
if not conf.CheckPKG('GTK+-2.0 >= 2.4.9'): if not conf.CheckPKG('gtk+-2.0 >= 2.4.9'):

The simplest way is to do something like this:

   1 # use GTK
   2 CCFLAGS = ' `pkg-config --cflags gtk+-2.0` '
   3 LINKFLAGS = ' `pkg-config --libs gtk+-2.0` '
   4 
   5 env = Environment(CCFLAGS=CCFLAGS, LINKFLAGS=LINKFLAGS)
   6 env.Program('toaster-test.c')

Remember to keep them separate, you cannot do what you do in makefiles and specify --cflags and --libs together.

However, the cleaner, more correct - and really not much harder - way is to use ParseConfig like so:

   1 env = Environment()
   2 
   3 # add support for GTK
   4 env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
   5 
   6 env.Program('toaster-test.c')

Of course, the above steps assume pkg-config and GTK+ are installed (though they will almost always be). If you want your configuration to be able to check for the existence of pkg-config, use something like what follows:

   1 env = Environment()
   2 
   3 def CheckPKGConfig(context, version):
   4      context.Message( 'Checking for pkg-config... ' )
   5      ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0]
   6      context.Result( ret )
   7      return ret
   8 
   9 def CheckPKG(context, name):
  10      context.Message( 'Checking for %s... ' % name )
  11      ret = context.TryAction('pkg-config --exists \'%s\'' % name)[0]
  12      context.Result( ret )
  13      return ret
  14 
  15 # Configuration:
  16 
  17 conf = Configure(env, custom_tests = { 'CheckPKGConfig' : CheckPKGConfig,
  18                                        'CheckPKG' : CheckPKG })
  19 
  20 if not conf.CheckPKGConfig('0.15.0'):
  21      print 'pkg-config >= 0.15.0 not found.'
  22      Exit(1)
  23 
  24 if not conf.CheckPKG('gtk+-2.0 >= 2.4.9'):
  25      print 'GTK+-2.0 >= 2.4.9 not found.'
  26      Exit(1)
  27 
  28 # Your extra checks here
  29 
  30 env = conf.Finish()
  31 
  32 # Now, build:
  33 
  34 env.ParseConfig('pkg-config --cflags --libs gtk+-2.0')
  35 
  36 env.Program('toaster-test.c')

UsingPkgConfig (last edited 2013-04-03 15:04:16 by JoelAlmeida)