/[ascend]/trunk/ascend-config.in
ViewVC logotype

Annotation of /trunk/ascend-config.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1160 - (hide annotations) (download)
Tue Jan 16 13:16:35 2007 UTC (11 years, 10 months ago) by johnpye
File size: 2791 byte(s)
Fixed --cppflags
1 johnpye 683 #!@PYTHON@
2     from optparse import OptionParser
3 johnpye 922 import sys, platform
4 johnpye 683
5     #---------------------
6     # This file is generated automatically by SCons and installed in at INSTALL_BIN.
7     # Use it to query for local configuration of ASCEND on your system for example
8     # when building external 'plugins' such as external computations and external
9     # solvers etc.
10     #
11     # It's written in python since (because of SCons) we know we have Python on
12 johnpye 692 # this system already but we don't know that about unix shell (eg on Windows).
13 johnpye 683 #
14     # Note that SCons supports reading of the output from this script, using
15 johnpye 965 # features offered since version 0.96.91, although this functionality
16     # is a bit problematic on the Windows platform, and/or when paths contain spaces.
17 johnpye 683 #
18     # This file inspired by other software that uses the same approach, eg
19     # ginac-config, xft-config, cppunit-config.
20     #
21     # Type ascend-config --help for usage.
22     #---------------------
23    
24 johnpye 922 if platform.system()=="Windows":
25     import _winreg
26     x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
27     y= _winreg.OpenKey(x,r"SOFTWARE\ASCEND")
28     LIB,t = _winreg.QueryValueEx(y,"INSTALL_LIB")
29     BIN,t = _winreg.QueryValueEx(y,"INSTALL_BIN")
30     INCLUDE,t = _winreg.QueryValueEx(y,"INSTALL_INCLUDE")
31     ASCDATA,t = _winreg.QueryValueEx(y,"INSTALL_ASCDATA")
32     MODELS,t = _winreg.QueryValueEx(y,"INSTALL_MODELS")
33 johnpye 683
34 johnpye 922 _winreg.CloseKey(y)
35     _winreg.CloseKey(x)
36     else:
37     # If we're not in Windows, use the original values passed to us from SCons:
38     LIB="@INSTALL_LIB@"
39     BIN="@INSTALL_BIN@"
40     INCLUDE="@INSTALL_INCLUDE@"
41     ASCDATA="@INSTALL_ASCDATA@"
42     MODELS="@INSTALL_MODELS@"
43 johnpye 683
44     usage = "usage: %prog [--help,...]"
45     # the rest of this script is about returning those values in the standard way
46     parser = OptionParser(usage=usage, version="@VERSION@")
47    
48     parser.add_option("--libs", action="store_true", dest="libs", help="show linker flags (for ASCEND libraries)")
49     parser.add_option("--cppflags", action="store_true", dest="cppflags", help="show C pre-processor flags (for ASCEND header files)")
50     parser.add_option("--data", action="store_true", dest="data", help="show location of ASCEND data files")
51 johnpye 721 parser.add_option("--models", action="store_true", dest="models", help="show location of ASCEND model library")
52 johnpye 683
53     (options, args) = parser.parse_args()
54    
55     ok = False
56    
57     if options.cppflags:
58     include = ""
59     if INCLUDE!="/usr/include":
60     include=INCLUDE
61 johnpye 965 if -1!=include.find(" "):
62     print "-I\""+include+"\""
63     else:
64 johnpye 1160 print "-I"+include
65 johnpye 683 ok = True
66    
67     if options.libs:
68     libs = ""
69     if LIB!="/usr/lib":
70     libs = LIB
71 johnpye 965 if -1!=libs.find(" "):
72     print "-L\""+libs+"\" -lascend"
73     else:
74     print "-L"+libs+" -lascend"
75 johnpye 683 ok = True
76    
77     if options.data:
78     print ASCDATA
79     ok = True
80    
81 johnpye 721 if options.models:
82     print MODELS
83     ok = True
84    
85 johnpye 683 if not ok:
86 johnpye 721 sys.stderr.write("invalid option '%s' (use --help for more info)\n" % args)
87 johnpye 683 sys.exit(1)
88 johnpye 922

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