code: def generate(env):
      
      global GhostscriptAction
      # The following try-except block enables us to use the Tool
      # in standalone mode (without the accompanying pdf.py),
      # whenever we need an explicit call of gs via the Gs()
      # Builder ...
      try:
          if GhostscriptAction is None:
              GhostscriptAction = SCons.Action.Action('$GSCOM', '$GSCOMSTR')
      
          from SCons.Tool import pdf
          pdf.generate(env)
      
          bld = env['BUILDERS']['PDF']
          bld.add_action('.ps', GhostscriptAction)
      except ImportError as e:
          pass
  
      gsbuilder = SCons.Builder.Builder(action = SCons.Action.Action('$GSCOM', '$GSCOMSTR'))
      env['BUILDERS']['Gs'] = gsbuilder
      
      env['GS']      = gs
      env['GSFLAGS'] = SCons.Util.CLVar('-dNOPAUSE -dBATCH -sDEVICE=pdfwrite')
      env['GSCOM']   = '$GS $GSFLAGS -sOutputFile=$TARGET $SOURCES'
docs: Add Builders and construction variables for Ghostscript to an
      Environment.