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

Annotation of /trunk/pygtk/interface/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 315 - (hide annotations) (download)
Thu Feb 23 07:40:47 2006 UTC (18 years, 5 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 johnpye 132 SOURCE_ROOT = ../..
2    
3     CXX = g++
4 johnpye 190 CC = gcc
5 johnpye 132
6 johnpye 190
7 johnpye 191 ifeq ($(OSTYPE),"cygwin")
8     PLATFORM_CPPFLAGS = -DPY_LONG_LONG="long long"
9 johnpye 193 SO_SUFF = .dll
10 johnpye 191 else
11     PLATFORM_CPPFLAGS =
12 johnpye 193 SO_SUFF = .so
13 johnpye 191 endif
14 johnpye 190
15 johnpye 132 CXXFLAGS = -c -g
16    
17 johnpye 190 LD = libtool --mode=link gcc
18     LD_CXX = libtool --mode=link g++
19 johnpye 132
20 johnpye 190 # -lieee -ldl
21     LDFLAGS = -g -lm -lc -lstdc++
22 johnpye 132
23     # Are you on a dual processor machine?
24     _smp_mflags = -j2
25    
26 johnpye 255 CLASSES = library type module symchar \
27     instance instanceinterfacedata \
28     method name \
29 johnpye 212 reporter simulation set units dimensions extmethod \
30 johnpye 238 variable relation \
31 johnpye 221 solver curve plot \
32 johnpye 233 solverparameters solverparameter solverparameteriterator \
33 johnpye 310 solverstatus solverreporter \
34 johnpye 233 incidencematrix
35 johnpye 175
36 johnpye 132 OBJS = $(CLASSES:%=%.o)
37     HDRS = $(CLASSES:%=%.h)
38    
39     all:
40 johnpye 190 @echo "OS TYPE: $(OSTYPE)"
41 johnpye 132
42 johnpye 143 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 johnpye 132 #-------------------------
45     # Linking with ASCEND
46    
47 johnpye 189 USE_JAM_LIBS = 1
48 johnpye 132
49 johnpye 189 ARDIR = $(SOURCE_ROOT)/base/autotools/archive
50     ASC_BUILD_LIBS = cd $(SOURCE_ROOT)/base/autotools; make libs
51 johnpye 132
52 johnpye 143 # Libs now are named the same way on both autotools and jam builds...
53 johnpye 132 ASC_LIBS_STEM = compiler packages solver utilities general
54 johnpye 143 ASC_LIBS = $(ASC_LIBS_STEM:%=$(ARDIR)/libasc%.a)
55 johnpye 132
56     $(ASC_LIBS): libs
57    
58     .PHONY: libs
59    
60     libs:
61 johnpye 189 @echo $(ASC_LIBS)
62 johnpye 143 $(ASC_BUILD_LIBS)
63 johnpye 132
64     #------------------
65     # PYTHON STUFF
66    
67 johnpye 153 USE_PYTHON := 1
68 johnpye 132
69 johnpye 138 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 johnpye 190 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 johnpye 138 endif
87     endif
88 johnpye 132
89 johnpye 151 ifeq ($(USE_PYTHON),1)
90 johnpye 132 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 johnpye 190 -rm *$(SO_SUFF)
99 johnpye 132 -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 johnpye 143 cd $(SOURCE_ROOT)/jam; \
110     jam clean;
111 johnpye 132
112     #--------------------------
113     # Pure C++ testing
114    
115 johnpye 190 CPPFLAGS := $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS)
116 johnpye 132
117     main: main.o $(OBJS) $(ASC_LIBS)
118     $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
119    
120     #------------------------
121     # SWIG targets
122    
123 johnpye 315
124 johnpye 132 SWIG_MODULE = ascend
125     SWIG = swig
126 johnpye 138
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 johnpye 315 SWIG_VERSION = $(shell $(SWIG) -version | grep "^SWIG Version " | sed s/SWIG\ Version\ \\\([0-9][0-9]*\\\(\\.[0-9][0-9]*\\\)*\\\).*/\\1/)
133 johnpye 138 SWIG_INCLUDES =
134     endif
135    
136 johnpye 315 # 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 johnpye 138 SWIGFLAGS = -c++ -python $(SWIG_INCLUDES)
151 johnpye 132 SWIG_CFLAGS = -c -fPIC
152 johnpye 190 SWIG_CPPFLAGS = $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS)
153 johnpye 132
154     SWIG_OBJS = $(SWIG_MODULE:%=%_wrap.o)
155 johnpye 315 SWIG_PY = $(SWIG_MODULE:%=%.py)
156 johnpye 132
157 johnpye 190 LIB = _ascend$(SO_SUFF)
158 johnpye 132
159     all: $(LIB)
160    
161 johnpye 221 SWIGS = plot.i solver.i
162 johnpye 176
163 johnpye 132 # FIXME add ' $(ASC_LIBS)' to deps once Jam build is fixed:
164 johnpye 176 %_wrap.cxx %.py: %.i $(SWIGS) $(HDRS)
165 johnpye 315 SWIG_FEATURES=$(SWIG_FEATURES) $(SWIG) $(SWIGFLAGS) $<
166 johnpye 132
167 johnpye 164 .precious: $(SWIG_MODULE:%=%_wrap.cxx)
168 johnpye 132 .precious: _ascend.so
169    
170     %_wrap.o: %_wrap.cxx
171     $(CC) $(SWIG_CFLAGS) -o $@ $^ $(SWIG_CPPFLAGS)
172    
173 johnpye 315 $(LIB): $(ASC_LIBS) $(OBJS) $(SWIG_OBJS) $(SWIG_PY)
174     $(LD) -module -shared -o $@ $(ASC_LIBS) $(OBJS) $(SWIG_OBJS) $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
175 johnpye 132
176     #------------------------
177 johnpye 151 # 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 johnpye 153 $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
184 johnpye 151
185    
186     #------------------------
187 johnpye 195 # 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 johnpye 132 # 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