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 instance variable method name \ |
27 |
reporter simulation set units dimensions extmethod \ |
28 |
solver curve plot solverparameters |
29 |
|
30 |
OBJS = $(CLASSES:%=%.o) |
31 |
HDRS = $(CLASSES:%=%.h) |
32 |
|
33 |
all: |
34 |
@echo "OS TYPE: $(OSTYPE)" |
35 |
|
36 |
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 |
37 |
|
38 |
#------------------------- |
39 |
# Linking with ASCEND |
40 |
|
41 |
USE_JAM_LIBS = 1 |
42 |
|
43 |
ARDIR = $(SOURCE_ROOT)/base/autotools/archive |
44 |
ASC_BUILD_LIBS = cd $(SOURCE_ROOT)/base/autotools; make libs |
45 |
|
46 |
# Libs now are named the same way on both autotools and jam builds... |
47 |
ASC_LIBS_STEM = compiler packages solver utilities general |
48 |
ASC_LIBS = $(ASC_LIBS_STEM:%=$(ARDIR)/libasc%.a) |
49 |
|
50 |
$(ASC_LIBS): libs |
51 |
|
52 |
.PHONY: libs |
53 |
|
54 |
libs: |
55 |
@echo $(ASC_LIBS) |
56 |
$(ASC_BUILD_LIBS) |
57 |
|
58 |
#------------------ |
59 |
# PYTHON STUFF |
60 |
|
61 |
USE_PYTHON := 1 |
62 |
|
63 |
ifeq ($(USE_PYTHON),1) |
64 |
ifeq ($(OSTYPE),msys) |
65 |
PYTHON_VERSION := 24 |
66 |
PYTHON_ROOT := /c/Python$(PYTHON_VERSION) |
67 |
PYTHON_CPPFLAGS := -I$(PYTHON_ROOT)/include |
68 |
PYTHON_LDFLAGS := -L$(PYTHON_ROOT)/libs -lpython($PYTHON_VERSION) |
69 |
else |
70 |
ifeq ($(TERM),cygwin) |
71 |
PYTHON_VERSION := 24 |
72 |
PYTHON_ROOT := /cygdrive/c/Python$(PYTHON_VERSION) |
73 |
PYTHON_CPPFLAGS := -I$(PYTHON_ROOT)/include |
74 |
PYTHON_LDFLAGS := -L$(PYTHON_ROOT)/libs -lpython24 |
75 |
else |
76 |
PYTHON_VERSION := $(shell python -V 2>&1 | sed s/Python\ // | sed s/^\\\([0-9][0-9]*\\.[0-9][0-9]*\\\).*/\\1/ ) |
77 |
PYTHON_CPPFLAGS := -I/usr/include/python$(PYTHON_VERSION) |
78 |
PYTHON_LDFLAGS := -lpython$(PYTHON_VERSION) |
79 |
endif |
80 |
endif |
81 |
endif |
82 |
|
83 |
ifeq ($(USE_PYTHON),1) |
84 |
ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS) $(PYTHON_CPPFLAGS) -DASCXX_USE_PYTHON |
85 |
ASCXX_PYTHON_LDFLAGS := $(PYTHON_LDFLAGS) |
86 |
else |
87 |
ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS) |
88 |
ASCXX_PYTHON_LDFLAGS := |
89 |
endif |
90 |
|
91 |
clean: |
92 |
-rm *$(SO_SUFF) |
93 |
-rm *.o |
94 |
-rm *_wrap.cxx |
95 |
-rm *_wrap.c |
96 |
-rm *_wrap.o |
97 |
-rm ascend.py |
98 |
-rm main |
99 |
-rm *.pyc |
100 |
-rmdir .libs |
101 |
|
102 |
cleanall: clean |
103 |
cd $(SOURCE_ROOT)/jam; \ |
104 |
jam clean; |
105 |
|
106 |
#-------------------------- |
107 |
# Pure C++ testing |
108 |
|
109 |
CPPFLAGS := $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS) |
110 |
|
111 |
main: main.o $(OBJS) $(ASC_LIBS) |
112 |
$(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS) |
113 |
|
114 |
#------------------------ |
115 |
# SWIG targets |
116 |
|
117 |
SWIG_MODULE = ascend |
118 |
SWIG = swig |
119 |
|
120 |
ifeq ($(OSTYPE),msys) |
121 |
SWIG_VERSION = 1.3.27 |
122 |
SWIG_INCROOT = /usr/local/share/swig/$(SWIG_VERSION) |
123 |
SWIG_INCLUDES = -I$(SWIG_INCROOT) -I$(SWIG_INCROOT)/std -I$(SWIG_INCROOT)/python |
124 |
else |
125 |
SWIG_INCLUDES = |
126 |
endif |
127 |
|
128 |
SWIGFLAGS = -c++ -python $(SWIG_INCLUDES) |
129 |
SWIG_CFLAGS = -c -fPIC |
130 |
SWIG_CPPFLAGS = $(ASCXX_CPPFLAGS) $(PLATFORM_CPPFLAGS) |
131 |
|
132 |
SWIG_OBJS = $(SWIG_MODULE:%=%_wrap.o) |
133 |
|
134 |
LIB = _ascend$(SO_SUFF) |
135 |
|
136 |
all: $(LIB) |
137 |
|
138 |
SWIGS = plot.i |
139 |
|
140 |
# FIXME add ' $(ASC_LIBS)' to deps once Jam build is fixed: |
141 |
%_wrap.cxx %.py: %.i $(SWIGS) $(HDRS) |
142 |
$(SWIG) $(SWIGFLAGS) $< |
143 |
|
144 |
.precious: $(SWIG_MODULE:%=%_wrap.cxx) |
145 |
.precious: _ascend.so |
146 |
|
147 |
%_wrap.o: %_wrap.cxx |
148 |
$(CC) $(SWIG_CFLAGS) -o $@ $^ $(SWIG_CPPFLAGS) |
149 |
|
150 |
$(LIB): $(ASC_LIBS) $(OBJS) $(SWIG_OBJS) |
151 |
$(LD) -module -shared -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS) |
152 |
|
153 |
#------------------------ |
154 |
# Trying to debug this GDPITA '3' problem, bug #178 |
155 |
|
156 |
testsolverinit.o: testsolverinit.cpp |
157 |
$(CXX) -c $(CPPFLAGS) $(CFLAGS) -o $@ $^ |
158 |
|
159 |
testsolverinit: testsolverinit.o $(OBJS) $(ASC_LIBS) |
160 |
$(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS) |
161 |
|
162 |
|
163 |
#------------------------ |
164 |
# Trying to fix implementation of external functions |
165 |
|
166 |
testextfn.o: testextfn.cpp |
167 |
$(CXX) -c $(CPPFLAGS) $(CFLAGS) -o $@ $^ |
168 |
|
169 |
testextfn: testextfn.o $(OBJS) $(ASC_LIBS) |
170 |
$(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS) |
171 |
|
172 |
#------------------------ |
173 |
# Testing the Python module |
174 |
|
175 |
test: $(LIB) |
176 |
# @echo "Does module include 'do_solve_eval' symbol?" |
177 |
# nm $(LIB) | grep "do_solve_eval" | egrep -v "U" |
178 |
# @echo "Does module include 'system_build' symbol?" |
179 |
# nm $(LIB) | grep "system_build" | egrep -v "U" |
180 |
@echo "Can python load the $(LIB) file?" |
181 |
python -c "import _ascend" |
182 |
python librarytest.py |
183 |
|
184 |
#-------------------------- |
185 |
# tarfile |
186 |
|
187 |
tar: clean |
188 |
pushd $(SOURCE_ROOT) && \ |
189 |
tar jcvf pygtk.tar.bz2 pygtk/ && \ |
190 |
popd |
191 |
mv ../../pygtk.tar.bz2 . |
192 |
|
193 |
#-------------------------- |
194 |
# storing a patch |
195 |
|
196 |
patch: clean |
197 |
pushd $(SOURCE_ROOT)/base && \ |
198 |
svn diff > ../pygtk/interface/ascend-base.patch && \ |
199 |
popd |
200 |
pushd $(SOURCE_ROOT)/tcltk98 && \ |
201 |
svn diff > ../pygtk/interface/ascend-tcltk98.patch && \ |
202 |
popd |
203 |
|
204 |
#--------------------------- |
205 |
patchapplybase: clean |
206 |
pushd $(SOURCE_ROOT)/base && \ |
207 |
patch -p0 < ../pygtk/interface/ascend-base.patch && \ |
208 |
popd |
209 |
|