(no commit message)
[libt2n] / codegen / codegen.make
CommitLineData
e62269cb 1# Makefile snippet included by projects using libt2n-codegen
84b484fa
JT
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
e62269cb 11-include $(foreach i, $(CMDGROUPS), libt2ngroup_$(i).P)
84b484fa 12
630ececc 13libt2ngroup_%.P : Makefile
e62269cb 14 echo $@ : $($*_GROUP) > libt2ngroup_$*.P
84b484fa 15
e62269cb 16%.libt2nstamp : libt2ngroup_%.P $(LIBT2N_CODEGEN)
84b484fa
JT
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; \
e62269cb 26 $(LIBT2N_CODEGEN) $* $($*_GROUP:.cpp=.xml) && touch $@
84b484fa 27
5a7380a0 28LIBT2N_CODEGEN_BUILT = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
2c2d29e1 29BUILT_SOURCES += $(LIBT2N_CODEGEN_BUILT)
84b484fa 30
2c2d29e1
JT
31LIBT2N_STAMPS=$(CMDGROUPS:=.libt2nstamp)
32$(BUILT_SOURCES) : $(LIBT2N_STAMPS)
84b484fa 33
2c2d29e1 34# Install the pkg-config files: (todo: perhaps use +=)
84b484fa
JT
35pkgconfigdir = $(libdir)/pkgconfig
36pkgconfig_DATA = $(CMDGROUPS:=.pc)
37
38# .pc files (one pc file for each command group)
1f0aa49f 39%.pc : $(LIBT2N_CLIENT_PCTEMPLATE) Makefile
84b484fa
JT
40 sed \
41 -e 's,@CMDGROUP@,$*,g' \
42 -e 's,\@prefix\@,$(prefix),g' \
43 -e 's,\@exec_prefix\@,$(exec_prefix),g' \
44 -e 's,\@libdir\@,$(libdir),g' \
45 -e 's,\@includedir\@,$(includedir),g' \
46 $< >$*.pc
47
2c2d29e1
JT
48LIBT2N_SUGGESTED_CLEANFILES = $(LIBT2N_CODEGEN_BUILT) $(LIBT2N_STAMPS) $(pkgconfig_DATA)
49
50# doesn't work
51# CLEANFILES = $(LIBT2N_SUGGESTED_CLEANFILES)
84b484fa
JT
52
53# didn't work (same problem as with _LTLIBRARIES [parsing by automake],
54# this time _OBJECTS was not correct)
55# server_SOURCES = server.cpp \
56# $(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j))) \
57# $(foreach i, $(CMDGROUPS), $(i)_server.cpp)
58
59# we have got an old automake version (1.4-p5) which doesn't support nodist_
60# => we use the dist-hook
5a7380a0
JT
61# unfortunately dist-hook only works if directly visible for automake (=> not in this include)
62#dist-hook:
63# rm -vf $(foreach i, $(BUILT_SOURCES), $(distdir)/$(i))