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

Annotation of /trunk/ascend-config.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 922 - (hide annotations) (download)
Wed Nov 8 05:25:37 2006 UTC (17 years, 11 months ago) by johnpye
File size: 2551 byte(s)
Expanded the 'ascend-config' mechanism to be supported in Windows installations (On Windows, ascend-config is installed in $INSTDIR and uses the registry instead of hard-coded file paths).

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     # features offered since version 0.96.91
16     #
17     # This file inspired by other software that uses the same approach, eg
18     # ginac-config, xft-config, cppunit-config.
19     #
20     # Type ascend-config --help for usage.
21     #---------------------
22    
23 johnpye 922 if platform.system()=="Windows":
24     import _winreg
25     x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
26     y= _winreg.OpenKey(x,r"SOFTWARE\ASCEND")
27     LIB,t = _winreg.QueryValueEx(y,"INSTALL_LIB")
28     BIN,t = _winreg.QueryValueEx(y,"INSTALL_BIN")
29     INCLUDE,t = _winreg.QueryValueEx(y,"INSTALL_INCLUDE")
30     ASCDATA,t = _winreg.QueryValueEx(y,"INSTALL_ASCDATA")
31     MODELS,t = _winreg.QueryValueEx(y,"INSTALL_MODELS")
32 johnpye 683
33 johnpye 922 _winreg.CloseKey(y)
34     _winreg.CloseKey(x)
35     else:
36     # If we're not in Windows, use the original values passed to us from SCons:
37     LIB="@INSTALL_LIB@"
38     BIN="@INSTALL_BIN@"
39     INCLUDE="@INSTALL_INCLUDE@"
40     ASCDATA="@INSTALL_ASCDATA@"
41     MODELS="@INSTALL_MODELS@"
42 johnpye 683
43     usage = "usage: %prog [--help,...]"
44     # the rest of this script is about returning those values in the standard way
45     parser = OptionParser(usage=usage, version="@VERSION@")
46    
47     parser.add_option("--libs", action="store_true", dest="libs", help="show linker flags (for ASCEND libraries)")
48     parser.add_option("--cppflags", action="store_true", dest="cppflags", help="show C pre-processor flags (for ASCEND header files)")
49     parser.add_option("--data", action="store_true", dest="data", help="show location of ASCEND data files")
50 johnpye 721 parser.add_option("--models", action="store_true", dest="models", help="show location of ASCEND model library")
51 johnpye 683
52     (options, args) = parser.parse_args()
53    
54     ok = False
55    
56     if options.cppflags:
57     include = ""
58     if INCLUDE!="/usr/include":
59     include=INCLUDE
60     print "-I"+include
61     ok = True
62    
63     if options.libs:
64     libs = ""
65     if LIB!="/usr/lib":
66     libs = LIB
67     print "-L"+libs+" -lascend"
68     ok = True
69    
70     if options.data:
71     print ASCDATA
72     ok = True
73    
74 johnpye 721 if options.models:
75     print MODELS
76     ok = True
77    
78 johnpye 683 if not ok:
79 johnpye 721 sys.stderr.write("invalid option '%s' (use --help for more info)\n" % args)
80 johnpye 683 sys.exit(1)
81 johnpye 922

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