14cd67d31710b0984c9b39a9f25ac64b39018ed3
[libt2n] / example-codegen / Makefile.am
1 INCLUDES = -I$(top_srcdir)/src @BOOST_CPPFLAGS@ @CPPUNIT_CFLAGS@ -I$(top_srcdir)/codegen
2 LDADD = $(top_builddir)/src/libt2n.la @BOOST_SERIALIZATION_LIB@ @BOOST_LDFLAGS@
3
4 # list your command groups
5 CMDGROUPS = default other
6
7 # for each command group list the files to parse for LIBT2N_EXPORT
8 default_GROUP = default.cpp
9 # example of a command group using multiple cpp files
10 other_GROUP = other-1.cpp other-2.cpp
11
12 # foo.hxx must be listed manually
13 include_HEADERS = foo.hxx
14
15 # unfortunately we can't set those from variables
16 # because they are parsed by automake
17
18 libdefault_la_SOURCES = default_client.cpp
19 libother_la_SOURCES = other_client.cpp
20 lib_LTLIBRARIES = libdefault.la libother.la
21
22 # build an example server and client
23 client_SOURCES = client.cpp
24 client_LDADD = $(LDADD) libdefault.la libother.la
25
26 server_SOURCES = server.cpp \
27         $(other_GROUP) other_server.cpp \
28         $(default_GROUP) default_server.cpp \
29         foo.hxx
30
31 noinst_PROGRAMS = client server
32
33 # test script
34
35 TESTS = test
36
37 # always the same:
38
39 include_HEADERS += $(foreach i, $(CMDGROUPS), $(i)_client.hxx $(i).hxx)
40
41 #IFILES=$(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j)))
42
43 -include $(foreach i, $(CMDGROUPS), .deps/group_$(i).P)
44
45 .deps/group_%.P : Makefile.am
46         echo $@ : $($*_GROUP) > .deps/group_$*.P
47
48 %.stamp : .deps/group_%.P $(top_builddir)/codegen/codegen
49 # assuming we have some unix like shell (maybe even bash)
50         echo BUILT_SOURCES: $(BUILT_SOURCES)
51         cp -v $(top_srcdir)/codegen/codegen-stubhead.hxx $*_common.hxx;
52         echo > $*_server.hxx;
53 # todo use tmp file for xml file
54         for i in $($*_GROUP); do \
55                 gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $${i} -fxml=$${i%*.cpp}.xml; \
56         done; \
57         $(top_builddir)/codegen/codegen $* $($*_GROUP:.cpp=.xml) && touch $@
58
59 # assuming we have gnu make?
60 BUILT_SOURCES = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
61
62 STAMPS=$(CMDGROUPS:=.stamp)
63 $(BUILT_SOURCES) : $(STAMPS)
64
65 # Install the pkg-config files:
66 pkgconfigdir = $(libdir)/pkgconfig
67 pkgconfig_DATA = $(CMDGROUPS:=.pc)
68
69 # .pc files (one pc file for each command group)
70 %.pc : $(top_srcdir)/codegen/clientlib.pc.in Makefile
71         sed \
72         -e 's,@CMDGROUP@,$*,g' \
73         -e 's,\@prefix\@,$(prefix),g' \
74         -e 's,\@exec_prefix\@,$(exec_prefix),g' \
75         -e 's,\@libdir\@,$(libdir),g' \
76         -e 's,\@includedir\@,$(includedir),g' \
77         $< >$*.pc
78
79 CLEANFILES = $(BUILT_SOURCES) $(STAMPS) $(pkgconfig_DATA)