summaryrefslogtreecommitdiff
path: root/cpp/gen/Makefile.am
blob: eea08c957037ab7938b4c6ee113bdf757b0e0b7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
include gen-src.mk

BUILT_SOURCES = $(generated_sources)

# Distribute the generated sources, at least for now, since
# the generator code is in java.
EXTRA_DIST = $(BUILT_SOURCES)
MAINTAINERCLEANFILES = $(BUILT_SOURCES)

gentools_dir = $(srcdir)/../../gentools
spec_dir = $(srcdir)/../../specs
spec = $(spec_dir)/amqp-8.0.xml
gentools_srcdir = $(gentools_dir)/src/org/apache/qpid/gentools

timestamp: $(spec) $(java_sources) $(cxx_templates)
if BUILD_IN_MESSAGE_TREE
	rm -f $(generated_sources)
	cd $(gentools_srcdir) && rm -f *.class && $(JAVAC) *.java
	$(JAVA) -cp $(gentools_dir)/src org.apache.qpid.gentools.Main \
	        -c -o . -t $(gentools_dir)/templ.cpp $(spec)
else
	echo "warning: failed to regenerate gen/*.{cpp,h}" 1>&2
endif
	touch timestamp

EXTRA_DIST += timestamp
$(generated_sources): timestamp

DISTCLEANFILES = gen-src.mk
gen-src.mk: timestamp
	( echo 'generated_sources = '\\					\
	  && ls *.cpp *.h | sort -u | sed 's/.*/  & \\/;$$s/ \\//'	\
	) > $@-t
if BUILD_IN_MESSAGE_TREE
	( echo if BUILD_IN_MESSAGE_TREE;				\
	  echo 'java_sources = '\\					\
	    && find $(gentools_srcdir) -name '*.java'			\
		| sort -u | sed 's/.*/  & \\/;$$s/ \\//';		\
	  echo 'cxx_templates = '\\					\
	    && find $(gentools_dir)/templ.cpp -name '*.tmpl'		\
		| sort -u | sed 's/.*/  & \\/;$$s/ \\//';		\
	  echo endif							\
	) >> $@-t
endif
	mv $@-t $@