initial load of upstream version 1.06.32
[xmlrpc-c] / examples / Makefile
1 # Since the programs in this directories are examples for the user, this
2 # make file should be as ordinary as possible.  It should not rely heavily
3 # on included make files or configuration parameters.  It should not use
4 # libtool.  Also, we don't try to build or rebuild the libraries on which
5 # these programs depend.
6
7
8 ifeq ($(SRCDIR)x,x)
9 SRCDIR = $(CURDIR)/..
10 BUILDDIR = $(SRCDIR)
11 endif
12
13 default: all
14
15 include $(BUILDDIR)/Makefile.config
16
17 CFLAGS = $(CFLAGS_COMMON) $(CFLAGS_PERSONAL) $(CADD)
18 LDFLAGS = $(LADD)
19
20 # If this were a real application, working from an installed copy of
21 # Xmlrpc-c, XMLRPC_C_CONFIG would just be 'xmlrpc-c-config'.  It would be
22 # found in the user's PATH.
23 XMLRPC_C_CONFIG = $(BUILDDIR)/xmlrpc-c-config.test
24
25 CLIENTPROGS = \
26   auth_client \
27   query-meerkat \
28   synch_client \
29   xmlrpc_sample_add_client \
30   xmlrpc_asynch_client \
31
32 SERVERPROGS_CGI = \
33   xmlrpc_sample_add_server.cgi
34
35 SERVERPROGS_ABYSS = \
36   xmlrpc_inetd_server \
37   xmlrpc_socket_server \
38   xmlrpc_loop_server \
39   xmlrpc_sample_add_server \
40   xmlrpc_server_validatee \
41
42 # Build up PROGS:
43 PROGS = 
44
45 ifeq ($(ENABLE_ABYSS_SERVER),yes)
46   PROGS += $(SERVERPROGS_ABYSS)
47 endif
48
49 PROGS += gen_sample_add_xml
50
51 ifeq ($(MUST_BUILD_CLIENT),yes)
52   PROGS += $(CLIENTPROGS)
53 endif
54
55 ifeq ($(ENABLE_CGI_SERVER),yes)
56   PROGS += $(SERVERPROGS_CGI) 
57 endif
58
59 INCLUDES = $(shell $(XMLRPC_C_CONFIG) client abyss-server --cflags)
60
61 LDADD_CLIENT = \
62   $(shell $(XMLRPC_C_CONFIG) client --ldadd)
63
64 LDADD_SERVER_ABYSS = \
65   $(shell $(XMLRPC_C_CONFIG) abyss-server --ldadd)
66
67 LDADD_SERVER_CGI = \
68   $(shell $(XMLRPC_C_CONFIG) cgi-server --ldadd)
69
70 LDADD_BASE = \
71   $(shell $(XMLRPC_C_CONFIG) --ldadd)
72
73 all: $(PROGS)
74
75 ifeq ($(ENABLE_CPLUSPLUS),yes)
76   all: cpp/all
77 endif
78
79 .PHONY: cpp/all
80 cpp/all:
81         $(MAKE) -C $(dir $@) $(notdir $@)
82
83 $(CLIENTPROGS):%:%.o
84         $(CCLD) -o $@ $(LDFLAGS) $^ $(LDADD_CLIENT)
85
86 $(SERVERPROGS_CGI):%.cgi:%_cgi.o
87         $(CCLD) -o $@ $(LDFLAGS) $^ $(LDADD_SERVER_CGI)
88
89 $(SERVERPROGS_ABYSS):%:%.o
90         $(CCLD) -o $@ $(LDFLAGS) $^ $(LDADD_SERVER_ABYSS)
91
92 gen_sample_add_xml:%:%.o
93         $(CCLD) -o $@ $(LDFLAGS) $^ $(LDADD_BASE)
94
95 %.o:%.c
96         $(CC) -c $(INCLUDES) $(CFLAGS) $<
97
98 *.c: config.h xmlrpc_amconfig.h
99
100 config.h:
101         $(LN_S) $(BUILDDIR)/xmlrpc_config.h $@
102 xmlrpc_amconfig.h:
103         $(LN_S) $(BUILDDIR)/$@ .
104
105 include $(SRCDIR)/Makefile.common
106
107 .PHONY: clean
108 clean: clean-common
109         rm -f $(PROGS) config.h xmlrpc_amconfig.h
110         $(MAKE) -C cpp clean
111
112 .PHONY: distclean
113 distclean: clean
114
115 BINDIR=$(DESTDIR)$(bindir)
116
117 FILENAME_GENERATOR = "echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'"
118
119 INSTCMD =  "$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p \
120   $(BINDIR)/`$(FILENAME_GENERATOR)`"
121
122 .PHONY: install
123 install: $(PROGS)
124         @$(NORMAL_INSTALL)
125         $(MKINSTALLDIRS) $(BINDIR)
126         @list='$(bin_PROGRAMS)'; for p in $$list; do \
127           if test -f $$p; then \
128             echo "$(INSTCMD)"; $(INSTCMD); \
129           else :; \
130           fi; \
131         done
132
133 .PHONY: check
134 check:
135
136 .PHONY: dep depend
137 dep depend:
138 # We don't do dependencies in this directory, because it's supposed to be
139 # an example of what a program outside this package would do, so we can't
140 # go weaving it into the rest of the package.  Ergo, a developer must
141 # carefully clean and remake examples as he updates other parts of the tree.