libt2n: (reinhard) 1 Million is not enough! (+ doc fix)
[libt2n] / examples-codegen / example1 / codegen.make
... / ...
CommitLineData
1# Makefile snippet included by projects using libt2n-codegen
2
3# Asumptions:
4# gnu make (functions for transforming text)
5# sed is available
6
7include_HEADERS += $(foreach i, $(CMDGROUPS), $(i)_client.hxx $(i).hxx)
8
9# not needed but nice to have
10# IFILES=$(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j)))
11
12-include $(foreach i, $(CMDGROUPS), libt2ngroup_$(i).P)
13
14libt2ngroup_%.P : Makefile.am
15 echo $@ : $($*_GROUP) > libt2ngroup_$*.P
16
17%.libt2nstamp : libt2ngroup_%.P
18# assuming we have some unix like shell (maybe even bash)
19# echo BUILT_SOURCES: $(BUILT_SOURCES)
20# temporarily create _common.hxx file (will be overwritten by codegen below)
21 echo '#include "codegen-stubhead.hxx"' > $*_common.hxx;
22 echo '#include "$*.hxx"' >> $*_common.hxx;
23# todo use tmp file for xml file
24 for i in $($*_GROUP); do \
25 gccxml $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(srcdir)/$${i} -fxml=$${i%*.cpp}.xml; \
26 done && $(LIBT2N_CODEGEN) $* $($*_GROUP:.cpp=.xml) && for i in $($*_GROUP); do \
27 rm $${i%*.cpp}.xml; \
28 done && touch $@
29
30LIBT2N_CODEGEN_BUILT = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
31
32# using BUILT_SOURCES is a bit problematic (see also automake manual)
33BUILT_SOURCES += $(LIBT2N_CODEGEN_BUILT)
34
35LIBT2N_STAMPS=$(CMDGROUPS:=.libt2nstamp)
36$(BUILT_SOURCES) : $(LIBT2N_STAMPS)
37
38# Install the pkg-config files: (todo: perhaps use +=)
39pkgconfigdir = $(libdir)/pkgconfig
40pkgconfig_DATA = $(CMDGROUPS:=.pc)
41
42# .pc files (one pc file for each command group)
43%.pc : $(LIBT2N_CLIENT_PCTEMPLATE) Makefile
44 sed \
45 -e 's,\@CMDGROUP\@,$*,g' \
46 -e 's,\@prefix\@,$(prefix),g' \
47 -e 's,\@exec_prefix\@,$(exec_prefix),g' \
48 -e 's,\@libdir\@,$(libdir),g' \
49 -e 's,\@includedir\@,$(includedir),g' \
50 -e 's,\@VERSION\@,$(VERSION),g' \
51 $< >$*.pc
52
53CLEANFILES += $(LIBT2N_CODEGEN_BUILT) $(LIBT2N_STAMPS) $(pkgconfig_DATA)
54DISTCLEANFILES += $(foreach i, $(CMDGROUPS), libt2ngroup_$(i).P)
55
56# didn't work (same problem as with _LTLIBRARIES [parsing by automake],
57# this time _OBJECTS was not correct)
58# server_SOURCES = server.cpp \
59# $(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j))) \
60# $(foreach i, $(CMDGROUPS), $(i)_server.cpp)
61
62# we have got an old automake version (1.4-p5) which doesn't support nodist_
63# => we use this hack using the dist-hook
64dist-hook: $(LIBT2N_CODEGEN_BUILT)
65 rm -vf $(foreach i, $(LIBT2N_CODEGEN_BUILT), $(distdir)/$(i))
66
67EXTRA_DIST += codegen.make