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

Contents of /trunk/pygtk/interface/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 143 - (show annotations) (download)
Thu Dec 22 03:41:47 2005 UTC (18 years, 6 months ago) by johnpye
File size: 4017 byte(s)
Fixing for ability to use both autotools and jam libraries
1 SOURCE_ROOT = ../..
2
3 CXX = g++
4 CC = gcc
5
6 CXXFLAGS = -c -g
7
8 LD = libtool --mode=link gcc -export-dynamic
9 LD_CXX = libtool --mode=link g++ -export-dynamic
10
11 LDFLAGS = -g -lieee -lm -lc -ldl -lstdc++
12
13 # Are you on a dual processor machine?
14 _smp_mflags = -j2
15
16 CLASSES = library type module symchar instance variable method name reporter simulation set units dimensions extfn solver
17 OBJS = $(CLASSES:%=%.o)
18 HDRS = $(CLASSES:%=%.h)
19
20 all:
21
22
23 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
24
25 #-------------------------
26 # Linking with ASCEND
27
28 ASC_TOOLS = autotools
29
30 ifeq ($(ASCTOOLS),jam)
31 # If you build with jam
32 ARDIR = $(SOURCE_ROOT)/jam/Release/linux
33 ASC_BUILD_LIBS = cd $(SOURCE_ROOT)/jam; jam libs
34 else
35 ARDIR = $(SOURCE_ROOT)/base/autotools/archive
36 ASC_BUILD_LIBS = cd $(SOURCE_ROOT)/base/autotools; make libs
37 endif
38
39 # Libs now are named the same way on both autotools and jam builds...
40 ASC_LIBS_STEM = compiler packages solver utilities general
41 ASC_LIBS = $(ASC_LIBS_STEM:%=$(ARDIR)/libasc%.a)
42
43 $(ASC_LIBS): libs
44
45 .PHONY: libs
46
47 libs:
48 $(ASC_BUILD_LIBS)
49
50 #------------------
51 # PYTHON STUFF
52
53 USE_PYTHON := 1
54
55 ifeq ($(USE_PYTHON),1)
56 ifeq ($(OSTYPE),msys)
57 PYTHON_VERSION := 24
58 PYTHON_ROOT := /c/Python$(PYTHON_VERSION)
59 PYTHON_CPPFLAGS := -I$(PYTHON_ROOT)/include
60 PYTHON_LDFLAGS := -L$(PYTHON_ROOT)/libs -lpython($PYTHON_VERSION)
61 else
62 PYTHON_VERSION := $(shell python -V 2>&1 | sed s/Python\ // | sed s/^\\\([0-9][0-9]*\\.[0-9][0-9]*\\\).*/\\1/ )
63 PYTHON_CPPFLAGS := -I/usr/include/python$(PYTHON_VERSION)
64 PYTHON_LDFLAGS := -lpython$(PYTHON_VERSION)
65 endif
66 endif
67
68 ifdef USE_PYTHON
69 ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS) $(PYTHON_CPPFLAGS) -DASCXX_USE_PYTHON
70 ASCXX_PYTHON_LDFLAGS := $(PYTHON_LDFLAGS)
71 else
72 ASCXX_CPPFLAGS := $(ASCEND_CPPFLAGS)
73 ASCXX_PYTHON_LDFLAGS :=
74 endif
75
76
77 again: clean all
78
79 clean:
80 -rm *.so
81 -rm *.o
82 -rm *_wrap.cxx
83 -rm *_wrap.c
84 -rm *_wrap.o
85 -rm ascend.py
86 -rm main
87 -rm *.pyc
88 -rmdir .libs
89
90 cleanall: clean
91 cd $(SOURCE_ROOT)/jam; \
92 jam clean;
93
94 #--------------------------
95 # Pure C++ testing
96
97 CPPFLAGS := $(ASCXX_CPPFLAGS)
98
99 main: main.o $(OBJS) $(ASC_LIBS)
100 $(LD) -o $@ $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
101
102 #------------------------
103 # SWIG targets
104
105 SWIG_MODULE = ascend
106 SWIG = swig
107
108 ifeq ($(OSTYPE),msys)
109 SWIG_VERSION = 1.3.27
110 SWIG_INCROOT = /usr/local/share/swig/$(SWIG_VERSION)
111 SWIG_INCLUDES = -I$(SWIG_INCROOT) -I$(SWIG_INCROOT)/std -I$(SWIG_INCROOT)/python
112 else
113 SWIG_INCLUDES =
114 endif
115
116 SWIGFLAGS = -c++ -python $(SWIG_INCLUDES)
117 SWIG_CFLAGS = -c -fPIC
118 SWIG_CPPFLAGS = $(ASCXX_CPPFLAGS)
119
120 SWIG_OBJS = $(SWIG_MODULE:%=%_wrap.o)
121
122 LIB = _ascend.so
123
124 all: $(LIB)
125
126 # FIXME add ' $(ASC_LIBS)' to deps once Jam build is fixed:
127 %_wrap.cxx %.py: %.i $(HDRS)
128 $(SWIG) $(SWIGFLAGS) $<
129
130 .precious: $(CLASSES:%=%_wrap.cxx)
131 .precious: _ascend.so
132
133 %_wrap.o: %_wrap.cxx
134 $(CC) $(SWIG_CFLAGS) -o $@ $^ $(SWIG_CPPFLAGS)
135
136 $(LIB): $(OBJS) $(SWIG_OBJS) $(ASC_LIBS)
137 $(LD) -module -shared -o $(LIB) $^ $(LDFLAGS) $(ASCXX_PYTHON_LDFLAGS)
138
139 #------------------------
140 # Testing the Python module
141
142 test: $(LIB)
143 # @echo "Does module include 'do_solve_eval' symbol?"
144 # nm $(LIB) | grep "do_solve_eval" | egrep -v "U"
145 # @echo "Does module include 'system_build' symbol?"
146 # nm $(LIB) | grep "system_build" | egrep -v "U"
147 @echo "Can python load the $(LIB) file?"
148 python -c "import _ascend"
149 python librarytest.py
150
151 #--------------------------
152 # tarfile
153
154 tar: clean
155 pushd $(SOURCE_ROOT) && \
156 tar jcvf pygtk.tar.bz2 pygtk/ && \
157 popd
158 mv ../../pygtk.tar.bz2 .
159
160 #--------------------------
161 # storing a patch
162
163 patch: clean
164 pushd $(SOURCE_ROOT)/base && \
165 svn diff > ../pygtk/interface/ascend-base.patch && \
166 popd
167 pushd $(SOURCE_ROOT)/tcltk98 && \
168 svn diff > ../pygtk/interface/ascend-tcltk98.patch && \
169 popd
170
171 #---------------------------
172 patchapplybase: clean
173 pushd $(SOURCE_ROOT)/base && \
174 patch -p0 < ../pygtk/interface/ascend-base.patch && \
175 popd
176

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