title: Why the success of SCons build depends on variant_dir name?
body: <p>I am bored to death with such behavior. So in <strong>SConstruct</strong> file we have the last string like this one:</p>
  
  <pre><code>import compilers, os
  
  env = Environment(ENV = os.environ, TOOLS = ['default'])
  
  def set_compiler(compiler_name):
      env.Replace(FORTRAN = compiler_name)
      env.Replace(F77 = compiler_name)
      env.Replace(F90 = compiler_name)
      env.Replace(F95 = compiler_name)
  
  def set_flags(flags):
      env.Replace(FORTRANFLAGS = flags)
      env.Replace(F77FLAGS = flags)
      env.Replace(F90FLAGS = flags)
      env.Replace(F95FLAGS = flags)
  
  mod_dir_prefix = {
      "gfortran": "-J ",
      "ifort": "-???",
      "pgfortran": "-module " 
  }
  
  flags = {
      ("gfortran", "debug"): "-O0 -g -Wall -Wextra -pedantic -fimplicit-none -fbounds-check -fbacktrace",
      ("gfortran", "release"): "-O3",
      ("pgfortran", "debug"): "-O0 -g -C -traceback",
      ("pgfortran",  "release"): "-O4"
  }
  
  if not GetOption('clean'):
      print "\nAvailable Fortran compilers:\n"
  
      for k, v in compilers.compilers_dict().iteritems():
          print "%10s : %s" % (k, v)
  
      compiler = raw_input("\nChoose compiler: ")
  
      set_compiler(compiler)
  
      debug_or_release = raw_input("\nDebug or release: ")
  
      set_flags(flags[(compiler, debug_or_release)])
  
      env.Replace(FORTRANMODDIRPREFIX = mod_dir_prefix[compiler])
  
      env.Replace(LINK = compiler)
      env.Replace(LINKCOM = "$LINK -o $TARGET $LINKFLAGS $SOURCES $_LIBDIRFLAGS $_LIBFLAGS $_FRAMEWORKPATH $_FRAMEWORKS $FRAMEWORKSFLAGS")
      env.Replace(LINKFLAGS = "")
  
  env.Replace(FORTRANMODDIR = '#Mod')
  Export('env')
  
  SConscript('Sources/SConscript', variant_dir='Build', duplicate=0)
  </code></pre>
  
  <p>compilers.py is my own module to find some Fortran compilers which are available.</p>
  
  <p>In Sources folder we have a couple of Fortran source files. </p>
  
  <p><strong>Sources\SConscript</strong></p>
  
  <pre><code>Import('env')
  env.Program('app', Glob('*.f90'))
  </code></pre>
  
  <p>Scons supports Fortran and everything works fine.</p>
  
  <pre><code>gfortran -o Temp\kinds.o -c -O3 -JMod Sources\kinds.f90
  gfortran -o Temp\math.o -c -O3 -JMod Sources\math.f90
  gfortran -o Temp\sorts.o -c -O3 -JMod Sources\sorts.f90
  gfortran -o Temp\utils.o -c -O3 -JMod Sources\utils.f90
  gfortran -o Temp\main.o -c -O3 -JMod Sources\main.f90
  gfortran -o Temp\app.exe Temp\kinds.o Temp\main.o Temp\math.o Temp\sorts.o Temp\utils.o
  scons: done building targets.
  </code></pre>
  
  <p>After renaming variant_dir name to let say <code>#Bin</code> or <code>#Build</code> we get error message:</p>
  
  <pre><code>gfortran -o Bin\kinds.o -c -O3 -JMod Sources\kinds.f90
  gfortran -o Bin\main.o -c -O3 -JMod Sources\main.f90
  Sources\main.f90:3.11:
  
    USE sorts
             1
  Fatal Error: Can't open module file 'sorts.mod' for reading at (1): No such file or directory
  </code></pre>
  
  <p>Of course the order of compilation matters. But why it depends on variant_dir name? Seems like a bug, but maybe I'm doing something wrong.</p>
  
  <p>P.S. This behavior doesn't depend on <code>duplicate</code> variable value.<br>
  P.P.S. Tested with SCons 2.0.1 on Windows with Python 2.7 and Mac OS X with Python 2.5.1.</p>