summaryrefslogtreecommitdiff
path: root/cpp/gen
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/gen')
-rw-r--r--cpp/gen/Makefile.am23
-rwxr-xr-xcpp/gen/make-gen-src-mk.sh30
2 files changed, 32 insertions, 21 deletions
diff --git a/cpp/gen/Makefile.am b/cpp/gen/Makefile.am
index 5d9473f615..e1707b86c4 100644
--- a/cpp/gen/Makefile.am
+++ b/cpp/gen/Makefile.am
@@ -6,7 +6,7 @@ pkginclude_HEADERS=$(generated_headers)
# Distribute the generated sources, at least for now, since
# the generator code is in java.
EXTRA_DIST = $(BUILT_SOURCES)
-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+DISTCLEANFILES = $(BUILT_SOURCES) timestamp gen-src.mk
# Don't attempt to run the code generator unless configure has set
# CAN_GENERATE_CODE, indicating that the amqp.xml and tools needed
@@ -26,26 +26,7 @@ $(BUILT_SOURCES) timestamp: $(spec) $(java_sources) $(cxx_templates)
-c -o . -t $(gentools_dir)/templ.cpp $(spec)
touch timestamp
-DISTCLEANFILES = gen-src.mk
gen-src.mk: timestamp
- ( echo 'generated_sources = '\\ \
- && ls *.cpp | sort -u | sed 's/.*/ & \\/;$$s/ \\//'; \
- echo 'generated_headers = '\\ \
- && ls *.h | sort -u | sed 's/.*/ & \\/;$$s/ \\//'; \
- ) > $@-t
- ( echo if CAN_GENERATE_CODE; \
- 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 '# Empty rules, in case any of these files is removed,'; \
- echo '# renamed, or no longer generated.'; \
- echo '$$(spec):'; \
- echo '$$(java_sources):'; \
- echo '$$(cxx_templates):'; \
- echo endif \
- ) >> $@-t
+ ./make-gen-src-mk.sh $(gentools_dir) $(gentools_srcdir) >> $@-t
mv $@-t $@
endif
diff --git a/cpp/gen/make-gen-src-mk.sh b/cpp/gen/make-gen-src-mk.sh
new file mode 100755
index 0000000000..08eb8ea134
--- /dev/null
+++ b/cpp/gen/make-gen-src-mk.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Generate the gen-src.mk makefile fragment, to stdout.
+# Usage: <gentools_dir> <gentools_srcdir>
+
+gentools_dir=$1
+gentools_srcdir=$2
+
+wildcard() { echo `ls $* 2>/dev/null` ; }
+
+cat <<EOF
+generated_sources = `wildcard *.cpp`
+
+generated_headers = `wildcard *.h`
+
+if CAN_GENERATE_CODE
+
+java_sources = `wildcard $gentools_srcdir/*.java`
+
+cxx_templates = `wildcard $gentools_dir/templ.cpp/*.tmpl`
+
+# Empty rules in case one of these files is removed,
+# renamed or no longer generated.
+\$(spec):
+\$(java_sources):
+\$(cxx_templates):
+endif
+
+EOF
+
+