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

Contents of /trunk/ascend-config.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1999 - (show annotations) (download)
Wed Feb 25 07:52:42 2009 UTC (15 years, 6 months ago) by jpye
File size: 3872 byte(s)
Fix for SCons 1.2.0: problem with detection of g77 on MinGW.
Still need to test on Linux.
Modified ascend-config for Windows to output paths with double backslash, seems to fix a problem with ParseConfig in SCons 1.2.0.
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 #assume that these won't change too much on Windows...
38 EXTLIB_SUFFIX = "_ascend.dll"
39 EXTLIB_PREFIX = ""
40
41 _winreg.CloseKey(y)
42 _winreg.CloseKey(x)
43
44 try:
45 # if we have access to GetShortPathName, we'll use it...
46 import win32api
47 def munge1(s):
48 s1 = s
49 try:
50 # we can only munge the path if it actually exists
51 s1 = win32api.GetShortPathName(s)
52 s1 = s1.replace("\\","\\\\")
53 except:
54 # if it doesn't exist, we just return the un-munged path
55 pass
56 return s1
57 munge = munge1
58 except:
59 pass
60 else:
61 # If we're not in Windows, use the original values passed to us from SCons:
62 LIB="@INSTALL_LIB@"
63 BIN="@INSTALL_BIN@"
64 INCLUDE="@INSTALL_INCLUDE@"
65 ASCDATA="@INSTALL_ASCDATA@"
66 MODELS="@INSTALL_MODELS@"
67 EXTLIB_SUFFIX="@EXTLIB_SUFFIX@"
68 EXTLIB_PREFIX="@EXTLIB_PREFIX@"
69
70 usage = "usage: %prog [--help,...]"
71 # the rest of this script is about returning those values in the standard way
72 parser = OptionParser(usage=usage, version="@VERSION@")
73
74 parser.add_option("--libs", action="store_true", dest="libs", help="show linker flags (for ASCEND libraries)")
75 parser.add_option("--cppflags", action="store_true", dest="cppflags", help="show C pre-processor flags (for ASCEND header files)")
76 parser.add_option("--data", action="store_true", dest="data", help="show location of ASCEND data files")
77 parser.add_option("--models", action="store_true", dest="models", help="show location of ASCEND model library")
78 parser.add_option("--extlib-suffix", action="store_true", dest="extlibsuff", help="show suffix to be used with external libraries")
79 parser.add_option("--extlib-prefix", action="store_true", dest="extlibpref", help="show prefix to be used with external libraries")
80
81 (options, args) = parser.parse_args()
82
83 ok = False
84
85 if options.cppflags:
86 include = ""
87 if INCLUDE!="/usr/include":
88 include=INCLUDE
89 if -1!=include.find(" "):
90 print "-I"+munge(include)+""
91 elif len(include):
92 print "-I"+include
93 ok = True
94
95 if options.libs:
96 libs = ""
97 if LIB!="/usr/lib":
98 libs = LIB
99 if -1!=libs.find(" "):
100 print "-L"+munge(libs)+" -lascend"
101 else:
102 Lflag = ""
103 if len(libs):
104 Lflag = "-L"+libs+" "
105 print Lflag + "-lascend"
106 ok = True
107
108 if options.data:
109 print ASCDATA
110 ok = True
111
112 if options.models:
113 print MODELS
114 ok = True
115
116 if options.extlibsuff:
117 print EXTLIB_SUFFIX
118 ok = True
119
120 if options.extlibpref:
121 print EXTLIB_PREFIX
122 ok = True
123
124 if not ok:
125 sys.stderr.write("invalid option '%s' (use --help for more info)\n" % args)
126 sys.exit(1)

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