/[ascend]/trunk/scons/tcl-config
ViewVC logotype

Diff of /trunk/scons/tcl-config

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1946 by jpye, Sat Nov 8 01:10:49 2008 UTC revision 1947 by jpye, Mon Nov 10 01:04:27 2008 UTC
# Line 29  tclconfigfile = output.strip() Line 29  tclconfigfile = output.strip()
29    
30  f = file(tclconfigfile)  f = file(tclconfigfile)
31    
32  # default variables that are assumed to already be defined somehow  # default build environment variables that are assumed to already be defined
33    # note that these are normally given default values in GNU Make, but we're
34    # not inside make, so we might not have these.
35    # FIXME: could try importing these from the environment?
36  d = {  d = {
37      "CC":"gcc",      "CC":"gcc",
38      "CFLAGS":"",      "CFLAGS":"",
39      "LDFLAGS":"",      "LDFLAGS":"",
40      "AR":"",      "AR":"",
41      "LIBS":"",      "LIBS":"",
42      "VERSION":"$TCL_VERSION",      "VERSION":"",
43      "DBGX":"$TCL_DBGX"      "DBGX":""
44  }  }
45    
46    # regular expression used for variable substitution
47  import re  import re
48  r = re.compile(r'\$\{([A-Z_0-9]+)\}')  r = re.compile(r'\$\{([A-Z_0-9]+)\}')
49    
50    # variable substitution/expansion function
51  def expand(s,d):  def expand(s,d):
52      m = r.search(s)      m = r.search(s)
53      #print "MATCHING",s      #print "MATCHING",s
# Line 68  for l in f: Line 73  for l in f:
73    
74  import getopt, sys  import getopt, sys
75    
76  def usage():  def usage(progname):
77      print """%s [--cflags] [--libs]"""      print "%s [--cflags] [--libs] [--var=TCL_VAR_NAME] [--vars]" % progname
78        print "Output configuration variables for the Tcl script interpreter."
79        print "Options:"
80        print "\t--cflags           Compiler flags for C code that uses Tcl"
81        print "\t--libs             Linker flags for code that uses Tcl"
82        print "\t--vars             List all variables defined in tclConfig.sh"
83        print "\t--var=VARNAME      Output the value of a specific variable"
84        print "\nSee http://ascendwiki.cheme.cmu.edu/Tcl-config for more info."
85    
86  try:  try:
87      opts, args = getopt.getopt(sys.argv[1:], "h", ["help", "cflags", "libs"])      opts, args = getopt.getopt(sys.argv[1:], "h",
88            ["help", "cflags", "libs","var=","vars"]
89        )
90  except getopt.GetoptError, err:  except getopt.GetoptError, err:
91      print str(err)      print str(err)
92      usage()      usage(sys.argv[0])
93      sys.exit(2)      sys.exit(2)
94    
95  for o, a in opts:  for o, a in opts:
96      if o == "-h" or o == "--help":      if o == "-h" or o == "--help":
97          usage()          usage(sys.argv[0])
98          sys.exit()          sys.exit()
99      elif o == "--cflags":      elif o == "--cflags":
100          print d['TCL_INCLUDE_SPEC']          print d['TCL_INCLUDE_SPEC']
101      elif o == "--libs":      elif o == "--libs":
102          print d['TCL_LIB_SPEC']          print d['TCL_LIB_SPEC']
103        elif o == "--var":
104            if d.has_key(a):
105                print d[a]
106            else:
107                raise RuntimeError("Unknown variable '%s'" % a)
108        elif o == "--vars":
109            for k in d.keys():
110                print k
111      else:      else:
112          assert False, "unhandled option"          assert False, "unhandled option"
113    

Legend:
Removed from v.1946  
changed lines
  Added in v.1947

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22