From 6b5643a78ad552722567f5b73ca7e1ec042beb5f Mon Sep 17 00:00:00 2001
From: Eric Blossom <eb@comsec.com>
Date: Wed, 24 Nov 2010 18:22:51 -0800
Subject: Generate precise list of swig related output files.

This list is used to prune files from the distribution and to remove
exactly the generated files during make clean.  Passes distcheck.
---
 Makefile.swig | 40 +++++++++++++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 9 deletions(-)

(limited to 'Makefile.swig')

diff --git a/Makefile.swig b/Makefile.swig
index b4eddc9856..327b566e1e 100644
--- a/Makefile.swig
+++ b/Makefile.swig
@@ -25,6 +25,11 @@
 ## in Makefile.am's which require SWIG wrapping / compilation.
 ## For just installing .i files, this Makefile is not required.
 
+
+## include the built Makefile.swig.gen, always the one from the srcdir
+include $(srcdir)/Makefile.swig.gen
+
+
 ## swig flags
 ## -w511 turns off keyword argument warning
 ## "-outdir $(builddir)" writes all generated output files to
@@ -85,34 +90,51 @@ STD_SWIG_LA_LIB_ADD = -lstdc++
 
 STD_SWIG_CXX_FLAGS = @swig_CXXFLAGS@
 
+# We drive the dependencies off of swig_built_sources.  This variable
+# ends up containing only the generated .py and/or .scm files, not the .h
+# or .cc files.  This allows us to use the pattern rules in
+# Makefile.common to generate all the pieces without the parallel make
+# problems that occur when both the .py's and .cc's are in swig_built_sources.
+
 swig_built_sources =
 
-## include the built Makefile.swig.gen, always the one from the
-## srcdir; this must be included as the last item, because it depends
-## on variables defined above.
+# swig_all_built_sources contains swig_built_sources plus the .cc and .h files.
+# It contains the files to remove from the distribution and the files to
+# remove for make clean.
 
-include $(srcdir)/Makefile.swig.gen
+swig_all_built_sources =
 
 if PYTHON
 # Create a list of .py files based on the top level .i files.
 PYTHON_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(subst .i,.py,$(IFILE)))
 swig_built_sources += $(PYTHON_GEN)
+swig_all_built_sources += $(PYTHON_GEN)
+
+# Now add .h, .cc to _all_
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.h,$(IFILE)))
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,python/%.cc,$(IFILE)))
 endif
 
 if GUILE
 # Create a list of .scm files based on the top level .i files.
 GUILE_GEN = $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%.scm,$(IFILE)))
 swig_built_sources += $(GUILE_GEN)
+swig_all_built_sources += $(GUILE_GEN)
+
+# Now add -primitive.scm, .cc to _all_
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,gnuradio/%-primitive.scm,$(IFILE)))
+swig_all_built_sources += $(foreach IFILE,$(TOP_SWIG_IFILES), $(patsubst %.i,guile/%.cc,$(IFILE)))
 endif
 
+# N.B. Only $(swig_built_sources), not $(swig_all_built_sources)
 BUILT_SOURCES += $(swig_built_sources)
 
-# FIXME swig_all_built_sources
-no_dist_files = $(swig_built_sources)
+# Don't distribute any of the swig generated files
+no_dist_files = $(swig_all_built_sources)
 
-# FIXME swig_all_built_sources
-CLEANFILES += python/*.cc python/*.h python/*.lo python/*.o python/*.d
-CLEANFILES += guile/*.cc gnuradio/*.scm guile/*.lo guile/*.o guile/*.d
+CLEANFILES += $(swig_all_built_sources)
+CLEANFILES += python/*.lo python/*.o python/*.d
+CLEANFILES += guile/*.lo  guile/*.o  guile/*.d
 
 
 ## ------------------------------------------------------------------------
-- 
cgit v1.2.3