title: using scons to run a perl script (which autogenerates a series of files) then compile these files and create a static library
body: <p>I'm porting our project from make to scons and I'm encountering a few issues.
  We have a number of perl scripts that we run through make which generate a series of C++ source files.
  These files are then compiled into a static library.</p>
  
  <p>At present I can run the perl scripts through scons and compile the files with a bit of additional python scripting, however, it seems like there should be an easier way to do this.</p>
  
  <p>Also I'm finding that the scons script doesn't seem to  be executed linearly.  Parts of the script are being executed out of order.</p>
  
  <p>Here is my sconscript;</p>
  
  <pre><code>// SConscript file
  
  import platform
  import os
  import glob
  import time
  Import('directEnv')
  cohEnv = directEnv.Clone()
  
  includePath = Split("""
  #Direct/include
  #Direct/libsrc/liblog
  #Direct/libsrc/libtime
  #tools/include
  #Direct/include
  #Direct/engine
  """)
  
  if platform.machine() == 'i686':
      includePath = includePath + ['#tools/coh-cpp-v3.6-linux-x32/coherence-cpp/include']
  
  else:
      includePath = includePath + ['#tools/cohe-cpp-v3.5.3b465-linux-x64/coherence cpp/include']
  
  cohFiles = Split("""
  #Direct/include/IntApi.h 
  #Direct/include/MessagingApiRisk.h 
  #Direct/include/MessagingApiCommon.h
  """)
  
  cohEnv.Append(CPPPATH = includePath)
  cohEnv.Append(CCFLAGS = '-D_FILE_OFFSET_BITS=64 -DUTPBRIDGE -Wno-unused-variable')
  cohEnv.Append(LIBS = Split('nsl m rt'))
  
  #
  # Run Perl script - this generates approx 30 c++ source files
  #
  
  Clean('.', '#Direct/coh/cpp/CohMsgObj_0.cc')
  temp1 = cohEnv.RunPerl('#Direct/coh/cpp/CohMsgObj_0.cc', '#Direct/coh/BuildCohObjs.pl')
  Depends(temp1, '#Direct/coh/BuildCoherenceObjs.pl')
  Depends(temp1, '#Direct/include/IntApi.h')
  
  #
  # Run Perl script - this generates 3 c++ source files
  #
  
  Clean('.', '#Direct/coh/cpp/Print_BinV4.cc')
  temp2 = cohEnv.RunPerl('#Direct/coh/cpp/Print_BinV4.cc', '#Direct/coh/BuildCohObjsRisk.pl')
  Depends(temp2, '#Direct/coh/BuildCohObjsRisk.pl')
  
  #
  # Build the object and library
  #
  
  print os.getcwd()
  os.chdir('../../cpp')
  path = os.getcwd()
  print path
  
  # 
  # get all the c++ source files that we need to compile
  #
  
  List = []
  for infile in glob.glob(os.path.join(path, '*.cc')):
      List.append(infile)
  
  count = 0    
  suffix = ".cc"
  ObjectList = []
  
  #
  # create objects for each source file
  # I'm trying to create variables dynamically - incase the files which generates the 
  # source files change - I don;t want to manually list everything that needs to be compiled
  
  for item in List:
      locals()['obj%s' % count] = coherenceEnv.Object(item[:-len(suffix)] + '.o' , item)
      print "obj%s" % count
      ObjectList.append(coherenceEnv.Object(item[:-len(suffix)] + '.o' , item))
      count = count + 1
  
  #
  # create a static library using the newly created objects
  #
  
  cohLib = cohEnv.StaticLibrary(target = 'riskpo', source = [cohFiles, ObjectList])
  cohEnv.Install('#/lib', [cohLib])
  </code></pre>
  
  <p>At the moment this works, however its far from ideal.
  Is there a better more straighforward way to do this using basic scons commands,
  Also how can I enforce order on the flow of execution using scons.
  thanks
  D</p>