try to find workaround for old automake
[libt2n] / example-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
d37ba346
JT
9# not needed but nice to have
10# IFILES=$(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j)))
84b484fa 11
e62269cb 12-include $(foreach i, $(CMDGROUPS), libt2ngroup_$(i).P)
84b484fa 13
d37ba346 14libt2ngroup_%.P : Makefile.am
e62269cb 15 echo $@ : $($*_GROUP) > libt2ngroup_$*.P
84b484fa 16
d0a97d0b 17%.libt2nstamp : libt2ngroup_%.P
84b484fa 18# assuming we have some unix like shell (maybe even bash)
528c5faa 19# echo BUILT_SOURCES: $(BUILT_SOURCES)
84b484fa
JT
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) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(srcdir)/$${i} -fxml=$${i%*.cpp}.xml; \
26 done; \
e62269cb 27 $(LIBT2N_CODEGEN) $* $($*_GROUP:.cpp=.xml) && touch $@
84b484fa 28
5a7380a0 29LIBT2N_CODEGEN_BUILT = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
7f435356
JT
30
31# using BUILT_SOURCES is a bit problematic (see also automake manual)
2c2d29e1 32BUILT_SOURCES += $(LIBT2N_CODEGEN_BUILT)
84b484fa 33
2c2d29e1
JT
34LIBT2N_STAMPS=$(CMDGROUPS:=.libt2nstamp)
35$(BUILT_SOURCES) : $(LIBT2N_STAMPS)
84b484fa 36
2c2d29e1 37# Install the pkg-config files: (todo: perhaps use +=)
84b484fa
JT
38pkgconfigdir = $(libdir)/pkgconfig
39pkgconfig_DATA = $(CMDGROUPS:=.pc)
40
41# .pc files (one pc file for each command group)
1f0aa49f 42%.pc : $(LIBT2N_CLIENT_PCTEMPLATE) Makefile
84b484fa 43 sed \
7f435356 44 -e 's,\@CMDGROUP\@,$*,g' \
84b484fa
JT
45 -e 's,\@prefix\@,$(prefix),g' \
46 -e 's,\@exec_prefix\@,$(exec_prefix),g' \
47 -e 's,\@libdir\@,$(libdir),g' \
48 -e 's,\@includedir\@,$(includedir),g' \
7f435356 49 -e 's,\@VERSION\@,$(VERSION),g' \
84b484fa
JT
50 $< >$*.pc
51
d37ba346 52CLEANFILES += $(LIBT2N_CODEGEN_BUILT) $(LIBT2N_STAMPS) $(pkgconfig_DATA)
84b484fa
JT
53
54# didn't work (same problem as with _LTLIBRARIES [parsing by automake],
55# this time _OBJECTS was not correct)
56# server_SOURCES = server.cpp \
57# $(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j))) \
58# $(foreach i, $(CMDGROUPS), $(i)_server.cpp)
59
60# we have got an old automake version (1.4-p5) which doesn't support nodist_
7f435356
JT
61# => we use this hack using the dist-hook
62dist-hook: $(LIBT2N_CODEGEN_BUILT)
d37ba346
JT
63 rm -vf $(foreach i, $(LIBT2N_CODEGEN_BUILT), $(distdir)/$(i))
64
65EXTRA_DIST += codegen.make