|
1 # |
|
2 # Copyright 2004-2006 Intel Corporation |
|
3 # |
|
4 # Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 # you may not use this file except in compliance with the License. |
|
6 # You may obtain a copy of the License at |
|
7 # |
|
8 # http://www.apache.org/licenses/LICENSE-2.0 |
|
9 # |
|
10 # Unless required by applicable law or agreed to in writing, software |
|
11 # distributed under the License is distributed on an "AS IS" BASIS, |
|
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 # See the License for the specific language governing permissions and |
|
14 # limitations under the License. |
|
15 # |
|
16 |
|
17 # |
|
18 # Makefile for DTN2/applib |
|
19 # |
|
20 |
|
21 # Source files generated by rpcgen |
|
22 XDRSRCS := dtn_types_xdr.c |
|
23 |
|
24 # Sources for the simple client side of the library |
|
25 CLIENTLIB_SRCS := \ |
|
26 $(XDRSRCS) \ |
|
27 dtn_api.c \ |
|
28 dtn_errno.c \ |
|
29 dtn_ipc.c \ |
|
30 sdnv-c.c \ |
|
31 |
|
32 # Sources for the client-side library that depend on liboasys |
|
33 CLIENT_EXTRA_SRCS := \ |
|
34 APIEndpointIDOpt.cc \ |
|
35 |
|
36 # Sources for the server side of the library |
|
37 SERVERLIB_SRCS := \ |
|
38 $(XDRSRCS) \ |
|
39 APIServer.cc \ |
|
40 dtn_errno.c \ |
|
41 dtn_ipc.c \ |
|
42 |
|
43 CLIENTLIB_OBJS := $(CLIENTLIB_SRCS:.c=.o) |
|
44 CLIENTLIB_OBJS := $(CLIENTLIB_OBJS:.cc=.o) |
|
45 CLIENTLIB_OBJS := $(CLIENTLIB_OBJS) ../dtn-version.o |
|
46 |
|
47 CLIENT_EXTRA_OBJS := $(CLIENT_EXTRA_SRCS:.c=.o) |
|
48 CLIENT_EXTRA_OBJS := $(CLIENT_EXTRA_OBJS:.cc=.o) |
|
49 |
|
50 SERVERLIB_OBJS := $(SERVERLIB_SRCS:.c=.o) |
|
51 SERVERLIB_OBJS := $(SERVERLIB_OBJS:.cc=.o) |
|
52 |
|
53 ALLSRCS := $(CLIENTLIB_SRCS) $(CLIENT_EXTRA_SRCS) $(SERVERLIB_SRCS) |
|
54 |
|
55 # |
|
56 # Default target is to build the three libraries |
|
57 # |
|
58 all: libs |
|
59 |
|
60 # |
|
61 # Shorthand rule for versioned library extensions |
|
62 # |
|
63 VLIB = $(DTN_VERSION).a |
|
64 VSHLIB = $(DTN_VERSION).$(SHLIB_EXT) |
|
65 |
|
66 # |
|
67 # rpcgen emits code that has unused variables, so we can't use our |
|
68 # normally stringent warnings |
|
69 # |
|
70 %_xdr.o: %_xdr.c |
|
71 @rm -f $@; mkdir -p $(@D) |
|
72 $(CC) $(CPPFLAGS) $(CFLAGS_NOWARN) -c $< -o $@ |
|
73 |
|
74 # |
|
75 # Make sure SRCDIR is set (.. by default) |
|
76 # |
|
77 ifeq ($(SRCDIR),) |
|
78 SRCDIR := .. |
|
79 BUILDDIR := .. |
|
80 endif |
|
81 |
|
82 # |
|
83 # Include the common rules and the version rules |
|
84 # |
|
85 CLEAN_OTHER := cleanother |
|
86 .PHONY: cleanother |
|
87 cleanother: |
|
88 @echo "cleaning up miscellaneous generated files/directories... $(OTHER_FILES)" |
|
89 @rm -rf $(OTHER_FILES) |
|
90 |
|
91 include ../Rules.make |
|
92 include $(SRCDIR)/dtn-version.mk |
|
93 |
|
94 # |
|
95 # When dtn_types.x changes, we now manually rebuild dtn_types.h and |
|
96 # dtn_types_xdr.c |
|
97 # |
|
98 .PHONY: xdrs |
|
99 xdrs: |
|
100 -$(RM) -f dtn_types.h dtn_types_xdr.c |
|
101 rpcgen -h dtn_types.x -o dtn_types.h |
|
102 rpcgen -c dtn_types.x -o dtn_types_xdr.c |
|
103 |
|
104 # |
|
105 # The python and perl scripts need some environment variables to |
|
106 # properly set up the include and lib paths. |
|
107 # |
|
108 ifeq ($(SRCDIR),..) |
|
109 SWIG_BUILD_ENV := INCDIR=../.. LIBDIR=.. VERSION=$(DTN_VERSION) |
|
110 else |
|
111 SWIG_BUILD_ENV := INCDIR=$(SRCDIR) LIBDIR=.. VERSION=$(DTN_VERSION) |
|
112 endif |
|
113 |
|
114 # |
|
115 # For some install rules we need the prefix |
|
116 # |
|
117 ifneq ($(DESTDIR),) |
|
118 INSTALL_PREFIX := --prefix=$(DESTDIR)usr |
|
119 else |
|
120 INSTALL_PREFIX := |
|
121 endif |
|
122 |
|
123 # |
|
124 # SWIG rules to generate the language-specific bindings |
|
125 # |
|
126 .PHONY: swig |
|
127 swig: |
|
128 swig -c++ -tcl -w302 -o tcl/dtn_api_wrap_tcl.cc dtn_api.i |
|
129 swig -c++ -perl -w302 -shadow -o perl/dtn_api_wrap_perl.cc dtn_api.i |
|
130 swig -c++ -python -w302 -o python/dtn_api_wrap_python.cc -classic dtn_api.i |
|
131 |
|
132 # |
|
133 # Swig rules for Tcl |
|
134 # |
|
135 .PHONY: tclapi |
|
136 tclapi: tcl/libdtntcl-$(VSHLIB) |
|
137 tcl/libdtntcl-$(VSHLIB): tcl/dtn_api_wrap_tcl.o libdtnapi-$(VSHLIB) |
|
138 $(CXX) $(CXXFLAGS) $< $(LDFLAGS_SHLIB) $(LDFLAGS) \ |
|
139 -ldtnapi-$(DTN_VERSION) $(TCL_LDFLAGS) -o $@ |
|
140 |
|
141 # |
|
142 # Swig rules for Python |
|
143 # |
|
144 .PHONY: pythonapi pythonapi_install |
|
145 pythonapi: python/dtnapi.pyc |
|
146 python/dtnapi.pyc: python/setup.py python/dtn_api_wrap_python.cc libdtnapi-$(VSHLIB) |
|
147 cd python && $(SWIG_BUILD_ENV) python setup.py build |
|
148 cd python && python -c "import py_compile; py_compile.compile('dtnapi.py')" |
|
149 |
|
150 # |
|
151 # Need to create the python directory and symlink the relevant files |
|
152 # if we're not building in the source directory |
|
153 # |
|
154 python/setup.py: |
|
155 mkdir python && cd python && \ |
|
156 ln -s $(SRCDIR)/applib/python/dtnapi.py && \ |
|
157 ln -s $(SRCDIR)/applib/python/dtn_api_wrap_python.cc && \ |
|
158 ln -s $(SRCDIR)/applib/python/setup.py |
|
159 |
|
160 pythonapi_install: |
|
161 cd python && $(SWIG_BUILD_ENV) python setup.py install $(INSTALL_PREFIX) |
|
162 |
|
163 OTHER_FILES += python/MANIFEST python/dtnapi.pyc python/build python/dist |
|
164 |
|
165 # |
|
166 # Swig rules for Perl |
|
167 # |
|
168 .PHONY: perlapi perlapi_install |
|
169 perlapi: perl/dtn_api_wrap_perl.o |
|
170 |
|
171 perl/dtn_api_wrap_perl.o: perl/Makefile.PL perl/dtn_api_wrap_perl.cc libdtnapi-$(VSHLIB) |
|
172 cd perl && \ |
|
173 $(SWIG_BUILD_ENV) perl Makefile.PL CC=$(CXX) LD=$(CXX) CCFLAGS=$(CFLAGS) VERSION=$(DTN_VERSION) && make |
|
174 |
|
175 perlapi_install: perlapi |
|
176 cd perl && make install |
|
177 |
|
178 # |
|
179 # Need to create the perl directory and symlink the relevant files |
|
180 # if we're not building in the source directory |
|
181 # |
|
182 perl/Makefile.PL: |
|
183 mkdir perl && cd perl && \ |
|
184 ln -s $(SRCDIR)/applib/perl/Makefile.PL && \ |
|
185 ln -s $(SRCDIR)/applib/perl/dtn_api_wrap_perl.cc |
|
186 |
|
187 OTHER_FILES += perl/Makefile perl/Makefile.old perl/blib perl/dtnapi.bs perl/pm_to_blib |
|
188 |
|
189 # |
|
190 # Linking rules for the libraries. |
|
191 # |
|
192 libdtnapi-$(VLIB): $(CLIENTLIB_OBJS) |
|
193 rm -f $@ |
|
194 $(AR) ruc $@ $^ |
|
195 $(RANLIB) $@ || true |
|
196 |
|
197 libdtnapi-$(VSHLIB): $(CLIENTLIB_OBJS) |
|
198 rm -f $@ |
|
199 $(CXX) $(CXXFLAGS) $^ $(LDFLAGS_SHLIB) $(LDFLAGS) -o $@ |
|
200 |
|
201 libdtnapi++-$(VLIB): $(CLIENT_EXTRA_OBJS) |
|
202 rm -f $@ |
|
203 $(AR) ruc $@ $^ |
|
204 $(RANLIB) $@ || true |
|
205 |
|
206 libdtnapi++-$(VSHLIB): $(CLIENT_EXTRA_OBJS) libdtnapi.a |
|
207 rm -f $@ |
|
208 $(CXX) $(CXXFLAGS) $^ $(LDFLAGS_SHLIB) $(OASYS_LDFLAGS) libdtnapi.a $(LDFLAGS) -o $@ |
|
209 |
|
210 libdtnapisrv.a: $(SERVERLIB_OBJS) |
|
211 rm -f $@ |
|
212 $(AR) ruc $@ $^ |
|
213 $(RANLIB) $@ || true |
|
214 |
|
215 # |
|
216 # Generate symbolic links to the versioned libraries |
|
217 # |
|
218 %.a : %-$(VLIB) |
|
219 rm -f $@ |
|
220 cd `dirname $@` && ln -s `basename $<` `basename $@` |
|
221 |
|
222 %.$(SHLIB_EXT) : %-$(VSHLIB) |
|
223 rm -f $@ |
|
224 cd `dirname $@` && ln -s `basename $<` `basename $@` |
|
225 |
|
226 # |
|
227 # Generate the list of files that is built by default |
|
228 # |
|
229 LIBFILES = libdtnapi.a libdtnapi-$(VLIB) |
|
230 LIBFILES += libdtnapi++.a libdtnapi++-$(VLIB) |
|
231 LIBFILES += libdtnapisrv.a |
|
232 ifeq ($(SHLIBS),yes) |
|
233 LIBFILES += libdtnapi.$(SHLIB_EXT) libdtnapi-$(VSHLIB) |
|
234 LIBFILES += libdtnapi++.$(SHLIB_EXT) libdtnapi++-$(VSHLIB) |
|
235 LIBFILES += tcl/libdtntcl.$(SHLIB_EXT) tcl/libdtntcl-$(VSHLIB) |
|
236 endif |
|
237 |
|
238 ifneq ($(PYTHON_BUILD_EXT),) |
|
239 LIBFILES += python/dtnapi.pyc |
|
240 endif |
|
241 |
|
242 libs: $(LIBFILES) |