/[ascend]/trunk/pygtk/interface/Makefile
ViewVC logotype

Contents of /trunk/pygtk/interface/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 315 - (show annotations) (download)
Thu Feb 23 07:40:47 2006 UTC (18 years, 3 months ago) by johnpye
File size: 5763 byte(s)
Expanded the python solver reporter a little
Added detection of newer SWIG versions that can optimise (-O)
1 SOURCE_ROOT = ../..
2
3 CXX = g++
4 CC = gcc
5
6
7 ifeq ($(OSTYPE),"cygwin")
8 PLATFORM_CPPFLAGS = -DPY_LONG_LONG="long long"
9 SO_SUFF = .dll
10 else
11 PLATFORM_CPPFLAGS =
12 SO_SUFF = .so
13 endif
14
15 CXXFLAGS = -c -g
16
17 LD = libtool --mode=link gcc
18 LD_CXX = libtool --mode=link g++
19
20 # -lieee -ldl
21 LDFLAGS = -g -lm -lc -lstdc++
22
23 # Are you on a dual processor machine?
24 _smp_mflags = -j2
25
26 CLASSES = library type module symchar \
27 instance instanceinterfacedata \
28 method name \
29 reporter simulation set units dimensions extmethod \
30 variable relation \
31 solver curve plot \
32 solverparameters solverparameter solverparameteriterator \
33 solverstatus solverreporter \
34 incidencematrix
35
36 OBJS = $(CLASSES:%=%.o)
37 HDRS = $(CLASSES:%=%.h)
38
39 all:
40 @echo "OS TYPE: $(OSTYPE)"
41
42 ASCEND_CPPFLAGS = -I../../base/generic -I../../base/generic/solver -I../../base/generic/compiler -I../../base/generic/utilities -I../../base/generic/general -I../../base/generic/packages
43
44 #-------------------------
45 # Linking with ASCEND
46
47 USE_JAM_LIBS = 1
48
49 ARDIR = $(SOURCE_ROOT)/base/autotools/archive
50 ASC_BUILD_LIBS = cd $(SOURCE_ROOT)/base/autotools; make libs
51
52 # Libs now are named the same way on both autotools and jam builds...
53 ASC_LIBS_STEM = compiler packages solver utilities general
54 ASC_LIBS = $(ASC_LIBS_STEM:%=$(ARDIR)/libasc%.a)
55
56 $(ASC_LIBS): libs
57
58 .PHONY: libs
59
60 libs:
61 @echo $(ASC_LIBS)
62 $(ASC_BUILD_LIBS)
63
64 #------------------
65 # PYTHON STUFF
66
67 USE_PYTHON := 1
68
69 ifeq ($(USE_PYTHON),1)
70 ifeq ($(OSTYPE),msys)
71 PYTHON_VERSION := 24
72 PYTHON_ROOT := /c/Python$(PYTHON_VERSION)
73 PYTHON_CPPFLAGS := -I$(PYTHON_ROOT)/include
74 PYTHON_LDFLAGS := -L$(PYTHON_ROOT)/libs -lpython($PYTHON_VERSION)
75 else
76 ifeq ($(TERM),cygwin)
77 PYTHON_VERSION := 24
78 PYTHON_ROOT := /cygdrive/c/Python$(PYTHON_VERSION)
79 PYTHON_CPPFLAGS := -I$(PYTHON_ROOT)/include
80 PYTHON_LDFLAGS := -L$(PYTHON_ROOT)/libs -lpython24
81 else
82 PYTHON_VERSION := $(shell python -V 2>&1 | sed s/Python\ // | sed s/^\\\([0-9][0-9]*\\.[0-9][0-9]*\\\).*/\\1/ )
83 PYTHON_CPPFLAGS := -I/usr/include/python$(PYTHON_VERSION)
84 PYTHON_LDFLAGS := -lpython$(PYTHON_VERSION)
85 endif
86 endif
87 endif
88
89 ifeq ($(USE_PYTHON),1)
90 ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS) $(PYTHON_CPPFLAGS) -DASCXX_USE_PYTHON
91 ASCXX_PYTHON_LDFLAGS := $(PYTHON_LDFLAGS)
92 else
93 ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS)
94 ASCXX_PYTHON_LDFLAGS :=
95 endif
96
97 clean:
98 -rm *$(SO_SUFF)
99 -rm *.o
100 -rm *_wrap.cxx
101 -rm *_wrap.c
102 -rm *_wrap.o
103 -rm ascend.py
104 -rm main
105 -rm *.pyc
106 -rmdir .libs
107
108 cleanall: clean
109 cd $(SOURCE_ROOT)/jam; \
110 jam clean;
111
112 #--------------------------
113 # Pure C++ testing
114
115 CPPFLAGS := $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS)
116
117 main: main.o $(OBJS) $(ASC_LIBS)
118 $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
119
120 #------------------------
121 # SWIG targets
122
123
124 SWIG_MODULE = ascend
125 SWIG = swig
126
127 ifeq ($(OSTYPE),msys)
128 SWIG_VERSION = 1.3.27
129 SWIG_INCROOT = /usr/local/share/swig/$(SWIG_VERSION)
130 SWIG_INCLUDES = -I$(SWIG_INCROOT) -I$(SWIG_INCROOT)/std -I$(SWIG_INCROOT)/python
131 else
132 SWIG_VERSION = $(shell $(SWIG) -version | grep "^SWIG Version " | sed s/SWIG\ Version\ \\\([0-9][0-9]*\\\(\\.[0-9][0-9]*\\\)*\\\).*/\\1/)
133 SWIG_INCLUDES =
134 endif
135
136 # optimize for SWIG 1.3.28 and newer
137 SWIG_MAJOR = $(shell echo $(SWIG_VERSION) | sed s/^\\\([0-9]*\\\).*/\\1/)
138 SWIG_MINOR = $(shell echo $(SWIG_VERSION) | sed s/^[0-9]*\\.\\\([0-9]*\\\).*/\\1/)
139 SWIG_PATCH = $(shell echo $(SWIG_VERSION) | sed s/^[0-9]*\\.[0-9]*\\.\\\([0-9]*\\\).*/\\1/)
140
141 SWIG_FEATURES =
142 ifeq ($(SWIG_MAJOR),1)
143 ifeq ($(SWIG_MINOR),3)
144 ifeq ($(shell test $(SWIG_PATCH) -ge 28 && echo 1),1)
145 SWIG_FEATURES="-O"
146 endif
147 endif
148 endif
149
150 SWIGFLAGS = -c++ -python $(SWIG_INCLUDES)
151 SWIG_CFLAGS = -c -fPIC
152 SWIG_CPPFLAGS = $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS)
153
154 SWIG_OBJS = $(SWIG_MODULE:%=%_wrap.o)
155 SWIG_PY = $(SWIG_MODULE:%=%.py)
156
157 LIB = _ascend$(SO_SUFF)
158
159 all: $(LIB)
160
161 SWIGS = plot.i solver.i
162
163 # FIXME add ' $(ASC_LIBS)' to deps once Jam build is fixed:
164 %_wrap.cxx %.py: %.i $(SWIGS) $(HDRS)
165 SWIG_FEATURES=$(SWIG_FEATURES) $(SWIG) $(SWIGFLAGS) $<
166
167 .precious: $(SWIG_MODULE:%=%_wrap.cxx)
168 .precious: _ascend.so
169
170 %_wrap.o: %_wrap.cxx
171 $(CC) $(SWIG_CFLAGS) -o $@ $^ $(SWIG_CPPFLAGS)
172
173 $(LIB): $(ASC_LIBS) $(OBJS) $(SWIG_OBJS) $(SWIG_PY)
174 $(LD) -module -shared -o $@ $(ASC_LIBS) $(OBJS) $(SWIG_OBJS) $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
175
176 #------------------------
177 # Trying to debug this GDPITA '3' problem, bug #178
178
179 testsolverinit.o: testsolverinit.cpp
180 $(CXX) -c $(CPPFLAGS) $(CFLAGS) -o $@ $^
181
182 testsolverinit: testsolverinit.o $(OBJS) $(ASC_LIBS)
183 $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
184
185
186 #------------------------
187 # Trying to fix implementation of external functions
188
189 testextfn.o: testextfn.cpp
190 $(CXX) -c $(CPPFLAGS) $(CFLAGS) -o $@ $^
191
192 testextfn: testextfn.o $(OBJS) $(ASC_LIBS)
193 $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
194
195 #------------------------
196 # Testing the Python module
197
198 test: $(LIB)
199 # @echo "Does module include 'do_solve_eval' symbol?"
200 # nm $(LIB) | grep "do_solve_eval" | egrep -v "U"
201 # @echo "Does module include 'system_build' symbol?"
202 # nm $(LIB) | grep "system_build" | egrep -v "U"
203 @echo "Can python load the $(LIB) file?"
204 python -c "import _ascend"
205 python librarytest.py
206
207 #--------------------------
208 # tarfile
209
210 tar: clean
211 pushd $(SOURCE_ROOT) && \
212 tar jcvf pygtk.tar.bz2 pygtk/ && \
213 popd
214 mv ../../pygtk.tar.bz2 .
215
216 #--------------------------
217 # storing a patch
218
219 patch: clean
220 pushd $(SOURCE_ROOT)/base && \
221 svn diff > ../pygtk/interface/ascend-base.patch && \
222 popd
223 pushd $(SOURCE_ROOT)/tcltk98 && \
224 svn diff > ../pygtk/interface/ascend-tcltk98.patch && \
225 popd
226
227 #---------------------------
228 patchapplybase: clean
229 pushd $(SOURCE_ROOT)/base && \
230 patch -p0 < ../pygtk/interface/ascend-base.patch && \
231 popd
232

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