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

Contents of /trunk/ascend-config.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1742 - (show annotations) (download)
Sat Feb 9 22:48:41 2008 UTC (10 years, 8 months ago) by jpye
File size: 3297 byte(s)
added path mungeing for Windows, fixed bug #365.
1 #!@PYTHON@
2 from optparse import OptionParser
3 import sys, platform
4
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 # this system already but we don't know that about unix shell (eg on Windows).
13 #
14 # Note that SCons supports reading of the output from this script, using
15 # 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 #
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 # platform specific name munging for '-L' and '-I' file paths...
25 munge = lambda s: s
26
27 if platform.system()=="Windows":
28 import _winreg
29 x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
30 y= _winreg.OpenKey(x,r"SOFTWARE\ASCEND")
31 LIB,t = _winreg.QueryValueEx(y,"INSTALL_LIB")
32 BIN,t = _winreg.QueryValueEx(y,"INSTALL_BIN")
33 INCLUDE,t = _winreg.QueryValueEx(y,"INSTALL_INCLUDE")
34 ASCDATA,t = _winreg.QueryValueEx(y,"INSTALL_ASCDATA")
35 MODELS,t = _winreg.QueryValueEx(y,"INSTALL_MODELS")
36
37 _winreg.CloseKey(y)
38 _winreg.CloseKey(x)
39
40 try:
41 # if we have access to GetShortPathName, we'll use it...
42 import win32api
43 def munge1(s):
44 s1 = s
45 try:
46 # we can only munge the path if it actually exists
47 s1 = win32api.GetShortPathName(s)
48 except:
49 # if it doesn't exist, we just return the un-munged path
50 pass
51 return s1
52 munge = munge1
53 except:
54 pass
55 else:
56 # If we're not in Windows, use the original values passed to us from SCons:
57 LIB="@INSTALL_LIB@"
58 BIN="@INSTALL_BIN@"
59 INCLUDE="@INSTALL_INCLUDE@"
60 ASCDATA="@INSTALL_ASCDATA@"
61 MODELS="@INSTALL_MODELS@"
62
63 usage = "usage: %prog [--help,...]"
64 # the rest of this script is about returning those values in the standard way
65 parser = OptionParser(usage=usage, version="@VERSION@")
66
67 parser.add_option("--libs", action="store_true", dest="libs", help="show linker flags (for ASCEND libraries)")
68 parser.add_option("--cppflags", action="store_true", dest="cppflags", help="show C pre-processor flags (for ASCEND header files)")
69 parser.add_option("--data", action="store_true", dest="data", help="show location of ASCEND data files")
70 parser.add_option("--models", action="store_true", dest="models", help="show location of ASCEND model library")
71
72 (options, args) = parser.parse_args()
73
74 ok = False
75
76 if options.cppflags:
77 include = ""
78 if INCLUDE!="/usr/include":
79 include=INCLUDE
80 if -1!=include.find(" "):
81 print "-I\""+munge(include)+"\""
82 elif len(include):
83 print "-I"+include
84 ok = True
85
86 if options.libs:
87 libs = ""
88 if LIB!="/usr/lib":
89 libs = LIB
90 if -1!=libs.find(" "):
91 print "-L\""+munge(libs)+"\" -lascend"
92 else:
93 Lflag = ""
94 if len(libs):
95 Lflag = "-L"+libs+" "
96 print Lflag + "-lascend"
97 ok = True
98
99 if options.data:
100 print ASCDATA
101 ok = True
102
103 if options.models:
104 print MODELS
105 ok = True
106
107 if not ok:
108 sys.stderr.write("invalid option '%s' (use --help for more info)\n" % args)
109 sys.exit(1)

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