initial load of upstream version 1.06.32
[xmlrpc-c] / Makefile.common
1 # -*-makefile-*-    <-- an Emacs control
2
3 # This file contains rules and variable settings for the convenience
4 # of every other make file in the package.
5
6 # No make file is required to use this file, but it usually saves a lot
7 # of duplication.
8
9 # The following make variables are meaningful as input to this file:
10 #
11 # SRCDIR:  Name of directory which is the top of the Xmlrpc-c source tree.
12 # BUILDDIR: Name of directory which is the top of the Xmlrpc-c build tree.
13
14 LIBTOOL = $(SRCDIR)/libtool
15 LINK = $(LIBTOOL) --mode=link $(CCLD)
16
17 GCC_WARNINGS = -Wall -Wundef -Wimplicit -W -Winline -Wundef
18   # We need -Wwrite-strings after we fix all the missing consts
19
20 GCC_C_WARNINGS = $(GCC_WARNINGS) \
21   -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes
22
23 GCC_CXX_WARNINGS = $(GCC_WARNINGS) -Woverloaded-virtual -Wsynth
24
25 # The NDEBUG macro says not to build code that assumes there are no bugs.
26 # This makes the code go faster.  The main thing it does is tell the C library
27 # to make assert() a no-op as opposed to generating code to check the
28 # assertion and crash the program if it isn't really true.  You can add
29 # -UNDEBUG (in any of various ways) to override this.
30 #
31 CFLAGS_COMMON = -DNDEBUG
32 CXXFLAGS_COMMON = -DNDEBUG
33
34 ifeq ($(C_COMPILER_GNU),yes)
35   CFLAGS_COMMON += $(GCC_C_WARNINGS) -fno-common -g -O3
36 endif
37
38 ifeq ($(CXX_COMPILER_GNU),yes)
39   CXXFLAGS_COMMON += $(GCC_CXX_WARNINGS) -g
40 endif
41
42 DISTDIR = $(BUILDDIR)/$(PACKAGE)-$(VERSION)/$(SUBDIR)
43
44 # MAJ and MIN are major and minor version numbers for shared libraries.
45 # Libtool builds are controlled by LDFLAGS_VERSINFO instead.
46 MAJ = 3
47 MIN = 06
48
49 # LDFLAGS_VERSINFO is a libtool link option (--version-info) that
50 # tells it what version numbers to put on the shared libraries (and
51 # maybe in those special libtool link files).  Exactly how it works is
52 # somewhat mysterious; it's designed to be part of a linking system
53 # where you always use libtool to link the libraries, and libtool
54 # figures out which if any version of a library meets the link's
55 # requirements.  But we expect our libraries to be linked with the
56 # regular (non-libtool) linker, so what we care about is the major,
57 # minor, and revision numbers in the file names and sonames.  Libtool
58 # has an option --version-number that supposedly lets us specify that,
59 # but it doesn't seem to work.  All I get is 0.0.0.  So we manipulate
60 # --version-info instead.
61 #
62 # This appears to work: in the option --version-info A.B.C:
63 #
64 #   C is the minor number
65 #   B is the revision number
66 #   A minus C is the major number.
67 #
68 # So you would get libxmlrpc.so.A-C.C.B .
69 #
70 # Our strategy is to make the library version numbers the same as the
71 # Xmlrpc-c version numbers except that we update the major number when and
72 # only when we make a non-backward-compatible change to the library.  So
73 # e.g. libxmlrpc for Xmlrpc-c 1.06.01 is named libxmlrpc.so.3.6.1.
74
75 LDFLAGS_VERSINFO = -version-info 9:15:6  # 3.6.15
76
77 # CURDIR was introduced in GNU Make 3.77.
78 ifeq ($(CURDIR)x,x)
79   CURDIR := $(shell /bin/pwd)
80 endif
81
82 LIBXMLRPC_UTIL           = $(BUILDDIR)/lib/libutil/libxmlrpc_util.la
83 LIBXMLRPC                = $(BUILDDIR)/src/libxmlrpc.la
84 LIBXMLRPC_CLIENT         = $(BUILDDIR)/src/libxmlrpc_client.la
85 LIBXMLRPC_SERVER         = $(BUILDDIR)/src/libxmlrpc_server.la
86 LIBXMLRPC_SERVER_ABYSS   = $(BUILDDIR)/src/libxmlrpc_server_abyss.la
87 LIBXMLRPC_SERVER_CGI     = $(BUILDDIR)/src/libxmlrpc_server_cgi.la
88 LIBXMLRPC_ABYSS          = $(BUILDDIR)/lib/abyss/src/libxmlrpc_abyss.la
89 LIBXMLRPC_XMLPARSE       = $(BUILDDIR)/lib/expat/xmlparse/libxmlrpc_xmlparse.la
90 LIBXMLRPC_XMLTOK         = $(BUILDDIR)/lib/expat/xmltok/libxmlrpc_xmltok.la
91 LIBXMLRPC_UTIL_A         = $(BUILDDIR)/lib/libutil/.libs/libxmlrpc_util.a
92 LIBXMLRPC_A              = $(BUILDDIR)/src/.libs/libxmlrpc.a
93 LIBXMLRPC_CLIENT_A       = $(BUILDDIR)/src/.libs/libxmlrpc_client.a
94 LIBXMLRPC_SERVER_A       = $(BUILDDIR)/src/.libs/libxmlrpc_server.a
95 LIBXMLRPC_SERVER_ABYSS_A = $(BUILDDIR)/src/.libs/libxmlrpc_server_abyss.a
96 LIBXMLRPC_SERVER_CGI_A   = $(BUILDDIR)/src/.libs/libxmlrpc_server_cgi.a
97 LIBXMLRPC_ABYSS_A        = $(BUILDDIR)/lib/abyss/src/.libs/libxmlrpc_abyss.a
98 LIBXMLRPC_XMLPARSE_A     = $(BUILDDIR)/lib/expat/xmlparse/.libs/libxmlrpc_xmlparse.a
99 LIBXMLRPC_XMLTOK_A       = $(BUILDDIR)/lib/expat/xmltok/.libs/libxmlrpc_xmltok.a
100 LIBXMLRPC_CPP            = $(BUILDDIR)/src/cpp/libxmlrpc_cpp.a
101 LIBXMLRPC++              = $(BUILDDIR)/src/cpp/libxmlrpc++.a
102 LIBXMLRPC_CLIENT++       = $(BUILDDIR)/src/cpp/libxmlrpc_client++.a
103 LIBXMLRPC_SERVER++       = $(BUILDDIR)/src/cpp/libxmlrpc_server++.a
104 LIBXMLRPC_SERVER_ABYSS++ = $(BUILDDIR)/src/cpp/libxmlrpc_server_abyss++.a
105
106 CASPRINTF                = $(BUILDDIR)/lib/util/casprintf.o
107
108 UTILS = $(CASPRINTF)
109
110
111 # LIBXMLRPC_XML is the list of Xmlrpc-c libraries we need to parse
112 # XML.  If we're using an external library to parse XML, this is null.
113 # LDLIBS_XMLRPC_XML is the corresonding -l options.
114
115 ifneq ($(ENABLE_LIBXML2_BACKEND),yes)
116   # We're using the internal Expat XML parser
117   LIBXMLRPC_XML = $(LIBXMLRPC_XMLPARSE) $(LIBXMLRPC_XMLTOK)
118   LDLIBS_XML = \
119         -L$(BUILDDIR)/lib/expat/xmlparse/.libs \
120         -lxmlrpc_xmlparse \
121         -L$(BUILDDIR)/lib/expat/xmltok/.libs \
122         -lxmlrpc_xmltok
123 else
124   LDLIBS_XML = $(shell xml2-config --libs)
125 endif
126
127
128 ##############################################################################
129 #                           BUILD RULES                                      #
130 ##############################################################################
131
132 # We use the srcdir and blddir symbolic links simply to make the make
133 # rules easier to read in the make output.  We could use $(SRCDIR) and
134 # $(BLDDIR) variables, but that makes the compile and link commands
135 # a mile long.  Note that Make sometime figures that a directory which
136 # is a dependency is newer than the symbolic link pointing to it and wants
137 # to rebuild the symbolic link.  So we don't make $(BLDDIR) a
138 # dependency of 'blddir'.
139
140 blddir:
141         $(LN_S) $(BLDDIR) $@
142
143 srcdir:
144         $(LN_S) $(SRCDIR) $@
145
146 $(SUBDIRS:%=%/all): %/all: $(CURDIR)/%
147         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
148             $(notdir $@) 
149
150 $(SUBDIRS:%=%/install): %/install: $(CURDIR)/%
151         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
152             $(notdir $@) 
153
154 $(SUBDIRS:%=%/clean): %/clean: $(CURDIR)/%
155         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
156             $(notdir $@) 
157
158 $(SUBDIRS:%=%/distclean): %/distclean: $(CURDIR)/%
159         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
160             $(notdir $@) 
161
162 $(SUBDIRS:%=%/check): %/check: $(CURDIR)/%
163         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
164             $(notdir $@) 
165
166 $(SUBDIRS:%=%/distdir): %/distdir: $(CURDIR)/%
167         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
168             $(notdir $@) 
169
170 $(SUBDIRS:%=%/dep): %/dep: $(CURDIR)/%
171         $(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
172             $(notdir $@) 
173
174 $(BUILDDIR)/lib/wininet_transport/xmlrpc_wininet_transport.lo: FORCE
175         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/wininet_transport/Makefile \
176             $(notdir $@)
177
178 $(BUILDDIR)/lib/curl_transport/xmlrpc_curl_transport.lo: FORCE
179         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/curl_transport/Makefile \
180             $(notdir $@)
181
182 $(BUILDDIR)/lib/libwww_transport/xmlrpc_libwww_transport.lo: FORCE
183         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/libwww_transport/Makefile \
184             $(notdir $@)
185
186 $(LIBXMLRPC_ABYSS): FORCE
187         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/abyss/src/Makefile \
188             $(notdir $@)
189
190 $(LIBXMLRPC_XMLPARSE): FORCE
191         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/expat/xmlparse/Makefile \
192             $(notdir $@)
193
194 $(LIBXMLRPC_XMLTOK): FORCE
195         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/expat/xmltok/Makefile \
196             $(notdir $@)
197
198 $(LIBXMLRPC_UTIL): FORCE
199         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/libutil/Makefile \
200             $(notdir $@)
201
202 $(LIBXMLRPC) $(LIBXMLRPC_CLIENT) $(LIBXMLRPC_SERVER): FORCE
203         $(MAKE) -C $(dir $@) -f $(SRCDIR)/src/Makefile \
204             $(notdir $@)
205
206 $(LIBXMLRPC++) $(LIBXMLRPC_CLIENT++) $(LIBXMLRPC_SERVER++) \
207   $(LIBXMLRPC_SERVER_ABYSS++): FORCE
208         $(MAKE) -C $(dir $@) -f $(SRCDIR)/src/cpp/Makefile \
209             $(notdir $@)
210
211 $(LIBXMLRPC_UTIL_A): $(LIBXMLRPC_UTIL)
212 $(LIBXMLRPC_A): $(LIBXMLRPC)
213 $(LIBXMLRPC_CLIENT_A): $(LIBXMLRPC_CLIENT)
214 $(LIBXMLRPC_SERVER_ABYSS_A): $(LIBXMLRPC_SERVER_ABYSS)
215 $(LIBXMLRPC_CGI_A): $(LIBXMLRPC_CGI)
216 $(LIBXMLRPC_ABYSS_A): $(LIBXMLRPC_ABYSS)
217 $(LIBXMLRPC_XMLPARSE_A): $(LIBXMLRPC_XMLPARSE)
218 $(LIBXMLRPC_XMLTOK_A): $(LIBXMLRPC_XMLTOK)
219
220 $(UTILS): FORCE
221         $(MAKE) -C $(dir $@) -f $(SRCDIR)/lib/util/Makefile \
222             $(notdir $@)
223
224 # About version.h:  This is a built header file, which means it is a supreme
225 # pain in the ass.  The biggest problem is that when we automatically make
226 # dependencies (Makefile.depend), it doesn't exist yet.  This means Gcc
227 # generates a dependency on it being in the local directory.  Therefore,
228 # we generate it in the local directory, as a symbolic link, wherever it
229 # is needed.  But the original is always in the top level directory,
230 # generated by a rule in that directory's make file.  Problem 2 is that
231 # the top directory's make file includes Makefile.common, so the rules
232 # below conflict with it.  That's what OMIT_VERSION_H is for.
233
234 ifneq ($(OMIT_VERSION_H),Y)
235
236 $(BUILDDIR)/version.h:
237         $(MAKE) -C $(dir $@) -f $(SRCDIR)/GNUmakefile $(notdir $@)
238
239 version.h: $(BUILDDIR)/version.h
240         $(LN_S) $< $@
241
242 endif
243
244 $(BUILDDIR)/include/xmlrpc-c/config.h:
245         $(MAKE) -C $(BUILDDIR)/include -f $(SRCDIR)/include/Makefile \
246           xmlrpc-c/config.h
247
248 ifneq ($(OMIT_TRANSPORT_CONFIG_H),Y)
249 $(BUILDDIR)/transport_config.h:
250         $(MAKE) -C $(dir $@) $(notdir $@)
251 endif
252
253 $(ALL_OBJS): $(BUILDDIR)/include/xmlrpc-c/config.h
254
255
256 ##############################################################################
257 #                          SHARED LIBRARY RULES                              #
258 ##############################################################################
259
260 ifeq ($(SHARED_LIB_TYPE),unix)
261   include $(SRCDIR)/unix-common.make
262   endif
263
264 ifeq ($(SHARED_LIB_TYPE),irix)
265   include $(SRCDIR)/irix-common.make
266   endif
267
268 ifeq ($(SHARED_LIB_TYPE),dll)
269   include $(SRCDIR)/dll-common.make
270   endif
271
272 ifeq ($(SHARED_LIB_TYPE),dylib)
273   include $(SRCDIR)/dylib-common.make
274   endif
275
276 ifeq ($(SHARED_LIB_TYPE),NONE)
277   install-shared-libraries:
278   endif
279
280
281 ##############################################################################
282 #                           INSTALL RULES                                    #
283 #                      (except shared libraries)                             #
284 ##############################################################################
285
286 MKINSTALLDIRS = $(SHELL) $(SRCDIR)/mkinstalldirs
287
288 .PHONY: install-common install-libraries install-headers install-bin
289 install-common: \
290   install-ltlibraries install-static-libraries install-shared-libraries \
291   install-headers install-bin
292
293 INSTALL_LIB_CMD = $(INSTALL_DATA) $$p $(DESTDIR)$(LIBINST_DIR)/$$p
294 RANLIB_CMD = $(RANLIB) $(DESTDIR)$(LIBINST_DIR)/$$p
295
296 install-static-libraries: $(STATIC_LIBRARIES_TO_INSTALL)
297         $(MKINSTALLDIRS) $(DESTDIR)$(LIBINST_DIR)
298         @list='$(STATIC_LIBRARIES_TO_INSTALL)'; for p in $$list; do \
299           if test -f $$p; then \
300             echo " $(INSTALL_LIB_CMD)"; \
301             $(INSTALL_LIB_CMD); \
302           else :; fi; \
303         done
304         @$(POST_INSTALL)
305         @list='$(STATIC_LIBRARIES_TO_INSTALL)'; for p in $$list; do \
306           if test -f $$p; then \
307             echo " $(RANLIB_CMD)"; \
308             $(RANLIB_CMD); \
309           else :; fi; \
310         done
311
312 LIBTOOL_INSTALL_CMD = $(LIBTOOL) --mode=install \
313   $(INSTALL_SHLIB) $$p $(DESTDIR)$(LIBINST_DIR)/$$p
314
315 install-ltlibraries: $(LTLIBRARIES_TO_INSTALL)
316         $(MKINSTALLDIRS) $(DESTDIR)$(LIBINST_DIR)
317         @list='$(LTLIBRARIES_TO_INSTALL)'; for p in $$list; do \
318           if test -f $$p; then \
319             echo " $(LIBTOOL_INSTALL_CMD)"; \
320             $(LIBTOOL_INSTALL_CMD); \
321           else :; fi; \
322         done
323
324 HEADERDESTDIR = $(DESTDIR)$(HEADERINST_DIR)
325 INSTALL_HDR_CMD = $(INSTALL_DATA) $$d$$p $(HEADERDESTDIR)/$$p 
326
327 install-headers: $(HEADERS_TO_INSTALL)
328         $(MKINSTALLDIRS) $(HEADERDESTDIR)
329         $(MKINSTALLDIRS) $(HEADERDESTDIR)/xmlrpc-c
330         @list='$(HEADERS_TO_INSTALL)'; for p in $$list; do \
331           if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \
332           echo " $(INSTALL_HDR_CMD)"; \
333           $(INSTALL_HDR_CMD); \
334         done
335
336
337 INSTALL_PROGRAM_CMD = $(INSTALL_PROGRAM) $$p $(DESTDIR)$(PROGRAMINST_DIR)/$$p
338
339 install-bin: $(PROGRAMS_TO_INSTALL) $(DESTDIR)$(PROGRAMINST_DIR)
340         @list='$(PROGRAMS_TO_INSTALL)'; \
341          for p in $$list; do \
342            echo "$(INSTALL_PROGRAM_CMD)"; \
343            $(INSTALL_PROGRAM_CMD); \
344            done
345
346 $(DESTDIR)$(PROGRAMINST_DIR):
347         $(MKINSTALLDIRS) $@
348
349
350 ##############################################################################
351 #                           MISCELLANEOUS RULES                              #
352 ##############################################################################
353
354 .PHONY: clean-common
355 clean-common:
356         rm -f *.o *.a *.s *.i *.la *.lo
357         rm -f *.$(SHLIB_SUFFIX) *.$(SHLIB_SUFFIX).*
358         rm -rf .libs
359
360 .PHONY: distclean-common
361 distclean-common:
362 # Makefile.depend is generated by 'make dep' and contains only dependencies
363 # that make parts get _rebuilt_ when parts upon which they depend change.
364 # It does not contain dependencies that are necessary to cause a part to
365 # get built in the first place.  E.g. if foo.c uses bar.h and bar.h gets built
366 # by a make rule, you must put the dependency of foo.c on bar.h somewhere
367 # besides Makefile.depend.
368 #
369 # Because of this, a user doesn't need Makefile.depend, because he
370 # doesn't modify source files.  A developer, on the other hand, must make his
371 # own Makefile.depend, because 'make dep' creates Makefile.depend with 
372 # absolute pathnames, specific to the developer's system.
373 #
374 # So we empty out Makefile.depend here.  The developer must do 'make dep' if
375 # he wants to edit and rebuild.
376 #
377 # Other projects have 'make distclean' _remove_ Makefile.depend and then
378 # have 'make' automatically build Makefile.depend.  We have
379 # found that to be an utter disaster -- it's way too complicated and prone
380 # to failure, especially with built .h files.  Better not to burden the user,
381 # who gains nothing from it, with that.
382 #
383         cat /dev/null >Makefile.depend
384         rm -f TAGS
385         rm -f blddir srcdir
386 ifneq ($(OMIT_VERSION_H),Y)
387         rm -f version.h
388 endif
389
390 .PHONY: distdir-common
391 distdir-common:
392         @for file in $(DISTFILES); do \
393           d=$(SRCDIR); \
394           if test -d $$d/$$file; then \
395             cp -pr $$d/$$file $(DISTDIR)/$$file; \
396           else \
397             test -f $(DISTDIR)/$$file \
398             || ln $$d/$$file $(DISTDIR)/$$file 2> /dev/null \
399             || cp -p $$d/$$file $(DISTDIR)/$$file || :; \
400           fi; \
401         done
402
403 TAGS: $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) $(LISP)
404         tags=; \
405         here=`pwd`; \
406         list='$(SUBDIRS)'; for subdir in $$list; do \
407    if test "$$subdir" = .; then :; else \
408             test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
409    fi; \
410         done; \
411         list='$(SOURCES) $(HEADERS)'; \
412         unique=`for i in $$list; do echo $$i; done | \
413           awk '    { files[$$0] = 1; } \
414                END { for (i in files) print i; }'`; \
415         test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
416           || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags  $$unique $(LISP) -o $$here/TAGS)
417
418 DEP_SOURCES = $(wildcard *.c *.cpp)
419
420 # This is a filter to turn "foo.o:" rules into "foo.o foo.lo:" because Libtool
421 # uses .lo for object files.  I'd like to purge the build of Libtool some day
422 # and eliminate this complication.
423
424 LIBTOOL_DEPEND_MASSAGER = perl -walnpe's{^(.*)\.o:}{$$1.o $$1.lo:}'
425
426
427
428 .PHONY: dep-common
429 dep-common: FORCE
430 ifneq ($(DEP_SOURCES)x,x)
431         -$(CC) -MM -MG -I. $(INCLUDES) $(DEP_SOURCES) | \
432           $(LIBTOOL_DEPEND_MASSAGER) \
433           >Makefile.depend
434 endif
435
436 Makefile.depend:
437         cat /dev/null >$@
438
439 # The automatic dependency generation is a pain in the butt and
440 # totally unnecessary for people just installing the distributed code,
441 # so to avoid needless failures in the field and a complex build, the
442 # 'distclean' target simply makes Makefile.depend an empty file.  A
443 # developer may do 'make dep' to create a Makefile.depend full of real
444 # dependencies.
445
446 # Tell versions [3.59,3.63) of GNU make to not export all variables.
447 # Otherwise a system limit (for SysV at least) may be exceeded.
448 .NOEXPORT:
449
450
451 # Use the FORCE target as a dependency to force a target to get remade
452 FORCE: