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

Annotation of /trunk/ascend-config.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1998 - (hide annotations) (download)
Thu Feb 19 01:54:19 2009 UTC (9 years, 8 months ago) by jpye
File size: 3839 byte(s)
Added EXTLIB_SUFFIX To ascend-config.
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 jpye 1742 # platform specific name munging for '-L' and '-I' file paths...
25     munge = lambda s: s
26    
27 johnpye 922 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 johnpye 683
37 jpye 1998 #assume that these won't change too much on Windows...
38     EXTLIB_SUFFIX = "_ascend.dll"
39     EXTLIB_PREFIX = ""
40    
41 johnpye 922 _winreg.CloseKey(y)
42     _winreg.CloseKey(x)
43 jpye 1742
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     except:
53     # if it doesn't exist, we just return the un-munged path
54     pass
55     return s1
56     munge = munge1
57     except:
58     pass
59 johnpye 922 else:
60     # If we're not in Windows, use the original values passed to us from SCons:
61     LIB="@INSTALL_LIB@"
62     BIN="@INSTALL_BIN@"
63     INCLUDE="@INSTALL_INCLUDE@"
64     ASCDATA="@INSTALL_ASCDATA@"
65     MODELS="@INSTALL_MODELS@"
66 jpye 1998 EXTLIB_SUFFIX="@EXTLIB_SUFFIX@"
67     EXTLIB_PREFIX="@EXTLIB_PREFIX@"
68 johnpye 683
69     usage = "usage: %prog [--help,...]"
70     # the rest of this script is about returning those values in the standard way
71     parser = OptionParser(usage=usage, version="@VERSION@")
72    
73     parser.add_option("--libs", action="store_true", dest="libs", help="show linker flags (for ASCEND libraries)")
74     parser.add_option("--cppflags", action="store_true", dest="cppflags", help="show C pre-processor flags (for ASCEND header files)")
75     parser.add_option("--data", action="store_true", dest="data", help="show location of ASCEND data files")
76 johnpye 721 parser.add_option("--models", action="store_true", dest="models", help="show location of ASCEND model library")
77 jpye 1998 parser.add_option("--extlib-suffix", action="store_true", dest="extlibsuff", help="show suffix to be used with external libraries")
78     parser.add_option("--extlib-prefix", action="store_true", dest="extlibpref", help="show prefix to be used with external libraries")
79 johnpye 683
80     (options, args) = parser.parse_args()
81    
82     ok = False
83    
84     if options.cppflags:
85     include = ""
86     if INCLUDE!="/usr/include":
87     include=INCLUDE
88 johnpye 965 if -1!=include.find(" "):
89 jpye 1743 print "-I"+munge(include)+""
90 jpye 1557 elif len(include):
91 johnpye 1160 print "-I"+include
92 johnpye 683 ok = True
93    
94     if options.libs:
95     libs = ""
96     if LIB!="/usr/lib":
97     libs = LIB
98 johnpye 965 if -1!=libs.find(" "):
99 jpye 1743 print "-L"+munge(libs)+" -lascend"
100 johnpye 965 else:
101 jpye 1557 Lflag = ""
102     if len(libs):
103     Lflag = "-L"+libs+" "
104     print Lflag + "-lascend"
105 johnpye 683 ok = True
106    
107     if options.data:
108     print ASCDATA
109     ok = True
110    
111 johnpye 721 if options.models:
112     print MODELS
113     ok = True
114    
115 jpye 1998 if options.extlibsuff:
116     print EXTLIB_SUFFIX
117     ok = True
118    
119     if options.extlibpref:
120     print EXTLIB_PREFIX
121     ok = True
122    
123 johnpye 683 if not ok:
124 johnpye 721 sys.stderr.write("invalid option '%s' (use --help for more info)\n" % args)
125 johnpye 683 sys.exit(1)
126 johnpye 922

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