Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Since the programs in this directory are examples for the user, this make
  2. # file should be as ordinary as possible. It should not rely heavily on
  3. # included make files or configuration parameters. Also, we don't try to
  4. # build or rebuild the libraries on which these programs depend or even
  5. # recognize that they've changed on their own.
  6. ifeq ($(SRCDIR),)
  7. SRCDIR = $(CURDIR)/..
  8. BLDDIR = $(SRCDIR)
  9. endif
  10. SUBDIR = examples
  11. include $(BLDDIR)/config.mk
  12. default: all
  13. CFLAGS = $(CFLAGS_PERSONAL) $(CADD)
  14. LDFLAGS += $(LADD)
  15. # If this were a real application, working from an installed copy of
  16. # Xmlrpc-c, XMLRPC_C_CONFIG would just be 'xmlrpc-c-config'. It would be
  17. # found in the user's PATH.
  18. XMLRPC_C_CONFIG = $(BLDDIR)/xmlrpc-c-config.test
  19. CLIENTPROGS = \
  20. auth_client \
  21. compound_value_client \
  22. synch_client \
  23. xmlrpc_sample_add_client \
  24. xmlrpc_asynch_client \
  25. ifeq ($(MUST_BUILD_CURL_CLIENT),yes)
  26. CLIENTPROGS += interrupted_client
  27. endif
  28. SERVERPROGS_CGI = \
  29. xmlrpc_sample_add_server.cgi
  30. SERVERPROGS_ABYSS = \
  31. compound_value_server \
  32. interrupted_server \
  33. xmlrpc_inetd_server \
  34. xmlrpc_socket_server \
  35. xmlrpc_loop_server \
  36. xmlrpc_sample_add_server \
  37. xmlrpc_server_validatee \
  38. BASIC_PROGS = \
  39. json \
  40. gen_sample_add_xml \
  41. # Build up PROGS:
  42. PROGS =
  43. PROGS += $(BASIC_PROGS)
  44. ifeq ($(ENABLE_ABYSS_SERVER),yes)
  45. PROGS += $(SERVERPROGS_ABYSS)
  46. endif
  47. ifeq ($(MUST_BUILD_CLIENT),yes)
  48. PROGS += $(CLIENTPROGS)
  49. endif
  50. ifeq ($(ENABLE_CGI_SERVER),yes)
  51. PROGS += $(SERVERPROGS_CGI)
  52. endif
  53. INCLUDES = -I. $(shell $(XMLRPC_C_CONFIG) client abyss-server --cflags)
  54. LIBS_CLIENT = \
  55. $(shell $(XMLRPC_C_CONFIG) client --libs)
  56. LIBS_SERVER_ABYSS = \
  57. $(shell $(XMLRPC_C_CONFIG) abyss-server --libs)
  58. LIBS_SERVER_CGI = \
  59. $(shell $(XMLRPC_C_CONFIG) cgi-server --libs)
  60. LIBS_BASE = \
  61. $(shell $(XMLRPC_C_CONFIG) --libs)
  62. all: $(PROGS)
  63. ifeq ($(ENABLE_CPLUSPLUS),yes)
  64. all: cpp/all
  65. endif
  66. .PHONY: cpp/all
  67. cpp/all: $(BLDDIR)/examples/cpp
  68. $(MAKE) -C cpp -f $(SRCDIR)/examples/cpp/Makefile all
  69. # When building in separate tree, directory won't exist yet
  70. $(BLDDIR)/examples/cpp:
  71. mkdir $@
  72. $(CLIENTPROGS):%:%.o
  73. $(CCLD) -o $@ $^ $(LIBS_CLIENT) $(LDFLAGS)
  74. $(SERVERPROGS_CGI):%.cgi:%_cgi.o
  75. $(CCLD) -o $@ $^ $(LIBS_SERVER_CGI) $(LDFLAGS)
  76. $(SERVERPROGS_ABYSS):%:%.o
  77. $(CCLD) -o $@ $^ $(LIBS_SERVER_ABYSS) $(LDFLAGS)
  78. $(BASIC_PROGS):%:%.o
  79. $(CCLD) -o $@ $^ $(LIBS_BASE) $(LDFLAGS)
  80. OBJECTS = $(patsubst %,%.o,$(patsubst %.cgi,%_cgi,$(PROGS)))
  81. $(OBJECTS):%.o:%.c
  82. $(CC) -c $(INCLUDES) $(CFLAGS) $<
  83. # config.h and xmlrpc_amconfig.h just describe the build environment.
  84. # We use them so that the example programs will build in users'
  85. # various environments. If you're copying these examples, you can
  86. # just remove these headers from the programs and hardcode whatever is
  87. # right for your build environment.
  88. $(OBJECTS): config.h xmlrpc_amconfig.h
  89. config.h:
  90. $(LN_S) $(BLDDIR)/xmlrpc_config.h $@
  91. xmlrpc_amconfig.h:
  92. $(LN_S) $(BLDDIR)/$@ .
  93. .PHONY: clean
  94. clean:
  95. rm -f $(PROGS) *.o config.h xmlrpc_amconfig.h
  96. $(MAKE) -C cpp clean
  97. .PHONY: distclean
  98. distclean: clean
  99. BINDIR=$(DESTDIR)$(bindir)
  100. FILENAME_GENERATOR = "echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'"
  101. INSTCMD = "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p \
  102. $(BINDIR)/`$(FILENAME_GENERATOR)`"
  103. .PHONY: install
  104. install: $(PROGS)
  105. @$(NORMAL_INSTALL)
  106. $(MKINSTALLDIRS) $(BINDIR)
  107. @list='$(bin_PROGRAMS)'; for p in $$list; do \
  108. if test -f $$p; then \
  109. echo "$(INSTCMD)"; $(INSTCMD); \
  110. else :; \
  111. fi; \
  112. done
  113. .PHONY: check
  114. check:
  115. .PHONY: dep depend
  116. dep depend:
  117. # We don't do dependencies in this directory, because it's supposed to be
  118. # an example of what a program outside this package would do, so we can't
  119. # go weaving it into the rest of the package. Ergo, a developer must
  120. # carefully clean and remake examples as he updates other parts of the tree.