#!/usr/bin/python import os import glob SConsignFile() config_h_defines = { # this is where all of your custom # configuration values "install_prefix": "/usr/", "version": "0.30", "version_long" : "0.30-rc1", "debug": 1, # this is an int. 1 for true, 0 for false "enable_binreloc": 1 # use BinReloc's prefix.c code } def ShouldRunConfigChecks(): if not os.path.exists('config.status'): return True if os.stat('SConstruct')[9] >= os.stat('config.status')[9]: return True if os.stat('src/SConscript')[9] >= os.stat('config.status')[9]: return True if os.stat('src/config.h.in')[9] >= os.stat('config.status')[9]: return True return False def CheckForHeader(header): split_header = header.split() for i in split_header: if not conf.CheckCHeader(i): print "Missing Header file: " + i Exit(1) def CheckForLibrary(library): split_library = library.split() for i in split_library: if not conf.CheckLib(i): print "Missing Library: " + i Exit(1) def print_config(msg, two_dee_iterable): # this function is handy and can be used for # other configuration-printing tasks print print msg print for key, val in two_dee_iterable: print " %-20s %s" % (key, val) print def config_h_build(target, source, env): #config_h_defines["foo"] = "hey look i added something else" print_config("Generating config.h with the following settings:", config_h_defines.items()) for a_target, a_source in zip(target, source): config_h = file(str(a_target), "w") config_h_in = file(str(a_source), "r") config_h.write(config_h_in.read() % config_h_defines) config_h_in.close() config_h.close() env = Environment(ENV = { 'PATH' : os.environ[ 'PATH' ], 'HOME' : os.environ[ 'HOME' ], # required for distcc }) # Debugging for developers if config_h_defines["debug"] == 1: env.Append(CCFLAGS = "-g -pedantic -Wall") # Gather source file names gnophone_sources = [] gnophone_sources.extend(glob.glob("src/*.c")) gnophone_sources.extend(glob.glob("src/*.h")) # GTK+ 2.x config options env.ParseConfig('pkg-config --cflags --libs gtk+-2.0') # Commented out -- not required right now # env.ParseConfig('gdk-pixbuf-config --cflags --libs') # env.ParseConfig('pkg-config --cflags --libs gdk-pixbuf-2.0') # env.ParseConfig('imlib-config --cflags --libs') # env.ParseConfig('pkg-config --cflags --libs imlib2') # env.ParseConfig('pkg-config --cflags --libs gdk-2.0') conf = Configure(env) #, custom_tests = { # "CheckForGTK" : CheckForGTK, # "CheckForGDKPixbuf" : CheckForGDKPixbuf # }) # linux/videodev.h if ShouldRunConfigChecks(): CheckForHeader('arpa/inet.h ctype.h dirent.h dlfcn.h errno.h fcntl.h getopt.h gdk/gdk.h gdk/gdkkeysyms.h gtk/gtk.h malloc.h math.h netdb.h netinet/in.h pthread.h sched.h stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/mman.h sys/resource.h sys/signal.h sys/socket.h sys/soundcard.h sys/stat.h sys/time.h sys/types.h sys/wait.h time.h unistd.h') os.system('touch config.status') env = conf.Finish() #build our config.h file configh = env.Command('src/config.h', 'src/config.h.in', config_h_build) # Files to compress if ARGUMENTS.get('dist', 0): env.Alias('dist', os.system('tar -cvf gnophone.tar --exclude CVS ../gnophone')) if ARGUMENTS.get('clean', 0): env.Clean('clean', 'src/config.h scache.conf') env.Alias('install', env.InstallAs(config_h_defines["install_prefix"] + '/share/gnophone/graphics/logo.png', 'icons/logo.png')) # Set up exports for child scripts Export("env config_h_defines") # Call to children scripts SConscript([ "src/SConscript", "src/modules/SConscript" ])