cleanup - simpliefied again by removing support for multiple command groups within...
[libt2n] / codegen / codegen.make
... / ...
CommitLineData
1# Makefile snippet included by projects using 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#IFILES=$(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j)))
10
11-include $(foreach i, $(CMDGROUPS), group_$(i).P)
12
13group_%.P : Makefile.am
14 echo $@ : $($*_GROUP) > group_$*.P
15
16%.stamp : group_%.P $(top_builddir)/codegen/codegen
17# assuming we have some unix like shell (maybe even bash)
18 echo BUILT_SOURCES: $(BUILT_SOURCES)
19# temporarily create _common.hxx file (will be overwritten by codegen below)
20 echo '#include "codegen-stubhead.hxx"' > $*_common.hxx;
21 echo '#include "$*.hxx"' >> $*_common.hxx;
22# todo use tmp file for xml file
23 for i in $($*_GROUP); do \
24 gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(srcdir)/$${i} -fxml=$${i%*.cpp}.xml; \
25 done; \
26 $(top_builddir)/codegen/codegen $* $($*_GROUP:.cpp=.xml) && touch $@
27
28BUILT_SOURCES = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
29
30STAMPS=$(CMDGROUPS:=.stamp)
31$(BUILT_SOURCES) : $(STAMPS)
32
33# Install the pkg-config files:
34pkgconfigdir = $(libdir)/pkgconfig
35pkgconfig_DATA = $(CMDGROUPS:=.pc)
36
37# .pc files (one pc file for each command group)
38%.pc : $(top_srcdir)/codegen/clientlib.pc.in Makefile
39 sed \
40 -e 's,@CMDGROUP@,$*,g' \
41 -e 's,\@prefix\@,$(prefix),g' \
42 -e 's,\@exec_prefix\@,$(exec_prefix),g' \
43 -e 's,\@libdir\@,$(libdir),g' \
44 -e 's,\@includedir\@,$(includedir),g' \
45 $< >$*.pc
46
47CLEANFILES = $(BUILT_SOURCES) $(STAMPS) $(pkgconfig_DATA)
48
49# didn't work (same problem as with _LTLIBRARIES [parsing by automake],
50# this time _OBJECTS was not correct)
51# server_SOURCES = server.cpp \
52# $(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j))) \
53# $(foreach i, $(CMDGROUPS), $(i)_server.cpp)
54
55# we have got an old automake version (1.4-p5) which doesn't support nodist_
56# => we use the dist-hook
57dist-hook:
58 rm -vf $(foreach i, $(BUILT_SOURCES), $(distdir)/$(i))