TryLink() a black hole (writing header/lib tests without pkgconfig)
Benjamin Reed
rangerrick at befunk.com
Mon Nov 7 01:15:50 CET 2005
I'm trying to write a test for libgif/libungif, but the SCons Try*
primitives are not very helpful as to what they're doing. This is the
test; I can't see any reason why this wouldn't work:
---(snip!)---
# Copyright Benjamin Reed 2005
# BSD license (see COPYING)
def exists(env):
return true
def generate(env):
from SCons.Options import Options
import os
optionFile = env['CACHEDIR'] + 'giflib.cache.py'
opts = Options(optionFile)
opts.AddOptions(
('CACHED_GIFLIB', 'Whether the GIF library is available'),
('CXXFLAGS_GIFLIB',''),
('LINKFLAGS_GIFLIB',''),
)
opts.Update(env)
if not env['HELP'] and (env['_CONFIGURE_'] or not
env.has_key('CACHED_GIFLIB')):
conf = env.Configure( )
env['CACHED_GIFLIB'] = 0
gifsource = """
#include <gif_lib.h>
int main(int argc, char **argv) {
if (GIF_OK != 1) {
return 1;
}
return 0;
}
"""
lastLIBS = env['LIBS']
for lib in [ 'gif', 'ungif' ]:
env.Replace(LIBS = [lib])
if conf.TryLink(gifsource, 'C'):
print "werd"
env['CXXFLAGS_GIFLIB'] = ['-DHAVE_GIFLIB']
env['LINKFLAGS_GIFLIB'] = ['-l' + lib]
env['CACHED_GIFLIB'] = 1
env.Replace(LIBS = lastLIBS)
break
else:
print "boo"
env['CACHED_GIFLIB'] = 0
env.Replace(LIBS = lastLIBS)
env = conf.Finish()
if not env['CACHED_GIFLIB']:
print 'libgif not found.'
---(snip!)---
Both tests print "boo" even though manually it works. I *do* rely on
EXTRAINCLUDES and EXTRALIBS for the test to pass, are they not being set
up for some reason?
Any ideas?
More information about the Kde-buildsystem
mailing list