[Lprof-devel] lprof SConstruct,1.11,1.12
Brought to you by:
hvengel
|
From: Hal E. <hv...@us...> - 2005-11-29 23:14:12
|
Update of /cvsroot/lprof/lprof In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23654 Modified Files: SConstruct Log Message: Bug # 1365009 QT support for Debian. This incorporates the code from the madman scons scripts. Tested on Gentoo. Needs to be tested on Debian and netBSD. Index: SConstruct =================================================================== RCS file: /cvsroot/lprof/lprof/SConstruct,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SConstruct 27 Nov 2005 21:51:28 -0000 1.11 --- SConstruct 29 Nov 2005 23:14:03 -0000 1.12 *************** *** 5,32 **** # Setup some of our requirements - env = Environment() - - optimize = ARGUMENTS.get('optimize', '-O2') - warnings = ARGUMENTS.get('warnings', 'y') - notiffio = ARGUMENTS.get('notiffio', 'n') # Get our configuration options: opts = Options('lprof.conf') opts.Add(PathOption('PREFIX', 'Directory to install under', '/usr/local')) ! opts.Add(EnumOption('optimize', 'compiler optimization values.', '-O2', allowed_values=('-O','-O1','-O2', '-O3', '-O0', '-Os'))) ! opts.Add(BoolOption('warnings', 'Turn on compiler warnings.', 1)) opts.Add(BoolOption('notiffio', 'Allow LPROF to build without tiff support.', 0)) opts.Update(env) opts.Save('lprof.conf', env) # Save, so user doesn't have to # specify PREFIX CFLAGS or CXXFLAGS every time - # set up compiler flags - if warnings in ['1', 'y', 'Y']: - FLAGS = optimize + ' -Wall' - else: - FLAGS = optimize - Help(opts.GenerateHelpText(env)) # ... put your configuration here ... --- 5,103 ---- # Setup some of our requirements # Get our configuration options: opts = Options('lprof.conf') + opts.Add("qt_directory", "Path to Qt directory", "not specified") opts.Add(PathOption('PREFIX', 'Directory to install under', '/usr/local')) ! opts.Add('cflags', 'Flags to be passed to c and c++ compilers.', '-O2 -Wall') opts.Add(BoolOption('notiffio', 'Allow LPROF to build without tiff support.', 0)) + + env = Environment( + ENV = { + 'PATH' : os.environ[ 'PATH' ], + 'HOME' : os.environ[ 'HOME' ] # required for distcc + }, options = opts) + opts.Update(env) opts.Save('lprof.conf', env) # Save, so user doesn't have to # specify PREFIX CFLAGS or CXXFLAGS every time Help(opts.GenerateHelpText(env)) + # Tool functions -------------------------------------------------------------- + def RunProgramAndGetResult(commandline): + file = os.popen(commandline, "r") + result = file.read().rstrip() + exit_code = file.close() + if exit_code is not None: + raise RuntimeError, "Program exited with non-zero exit code." + return result + + + + + def DoWithVariables(variables, prefix, what): + saved_variables = { } + for name in variables.keys(): + saved_variables[ name ] = env[ name ][:] + if isinstance(variables[ name ], list): + env[ name ].extend(variables[ name ]) + else: + env[ name ].append(variables[ name ]) + + result = what() + + for name in saved_variables.keys(): + env[ name ] = saved_variables[ name ] + env[ prefix+name ] = variables[ name ] + + return result + + # checks for QT ---------------------------------------------------------- + def CheckForQtAt(context, qtdir): + context.Message('Checking for Qt at %s... ' % qtdir) + result = AttemptLinkWithVariables(context, + { "LIBS": "qt-mt", "LIBPATH": qtdir + '/lib', "CPPPATH": qtdir + '/include' }, + """ + #include <qapplication.h> + int main(int argc, char **argv) { + QApplication qapp(argc, argv); + return 0; + } + """,".cpp","QT_") + context.Result(result) + return result + + + def CheckForQt(context): + potential_qt_dirs = [ + "/usr/share/qt3", # Debian unstable + "/usr/share/qt", + "/usr", + "/usr/local", + "/usr/lib/qt3", # Suse + "/usr/lib/qt", + "/usr/qt/3", # Gentoo + "/usr/pkg/qt3" # netBSD + ] + + if os.environ.has_key('QTDIR'): + potential_qt_dirs.insert(0, os.environ[ 'QTDIR' ]) + + if env[ 'qt_directory' ] != "not specified": + potential_qt_dirs.insert(0, env[ 'qt_directory' ]) + + for i in potential_qt_dirs: + if CheckForQtAt(context, i): + context.env.Replace(QTDIR = i) + return 1 + return 0 + + + def AttemptLinkWithVariables(context, variables, code, extension, prefix): + return DoWithVariables(variables, prefix, lambda: context.TryLink(code, extension)) + + + # ... put your configuration here ... *************** *** 39,48 **** # setup the include paths where qt, lcms and liblprof should live - env.Append(QTDIR=os.environ['QTDIR']) env.Append(CPPPATH=include_search_path) env.Append(LIBS=['m', 'png', 'tiff', 'lcms', 'Xext', 'X11', 'qassistantclient']) env.Append(LIBPATH=['/usr/X11R6/lib', 'src/liblprof', '/usr/lib', '$QTDIR/plugins/imageformats']) ! env.Append(CFLAGS=FLAGS) ! env.Append(CXXFLAGS=FLAGS) env.Tool('qt', ['$TOOL_PATH']) env['QT_LIB'] = 'qt-mt' --- 110,118 ---- # setup the include paths where qt, lcms and liblprof should live env.Append(CPPPATH=include_search_path) env.Append(LIBS=['m', 'png', 'tiff', 'lcms', 'Xext', 'X11', 'qassistantclient']) env.Append(LIBPATH=['/usr/X11R6/lib', 'src/liblprof', '/usr/lib', '$QTDIR/plugins/imageformats']) ! env.Append(CFLAGS=env ['cflags']) ! env.Append(CXXFLAGS=env ['cflags']) env.Tool('qt', ['$TOOL_PATH']) env['QT_LIB'] = 'qt-mt' *************** *** 50,54 **** # check system to make sure everything needed is available ! config=env.Configure() # look for lcms headers --- 120,131 ---- # check system to make sure everything needed is available ! ! # check for QT ! config=env.Configure(custom_tests = { ! "CheckForQt" : CheckForQt ! }) ! if not config.CheckForQt(): ! Exit(1) ! # look for lcms headers *************** *** 72,76 **** print "" # check for libtiff if tiffio support is enabled ! if notiffio in ['0', 'n', 'N']: if not config.CheckLib('libtiff'): print "You need to have libtiff installed" --- 149,153 ---- print "" # check for libtiff if tiffio support is enabled ! if env ['notiffio'] in ['0', 'n', 'N']: if not config.CheckLib('libtiff'): print "You need to have libtiff installed" *************** *** 79,83 **** # check for tiff plugin for QT ! if notiffio in ['0', 'n', 'N']: if not config.CheckLib('libTiffIO'): print "To build LPROF without TiffIO installed set notiffio=1" --- 156,160 ---- # check for tiff plugin for QT ! if env ['notiffio'] in ['0', 'n', 'N']: if not config.CheckLib('libTiffIO'): print "To build LPROF without TiffIO installed set notiffio=1" |