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

Contents of /trunk/pygtk/interface/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


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

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