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