gen-install-files depends on extract_install_filenames, so we need that too
authorBdale Garbee <bdale@gag.com>
Fri, 4 Sep 2009 02:54:02 +0000 (20:54 -0600)
committerBdale Garbee <bdale@gag.com>
Fri, 4 Sep 2009 02:54:02 +0000 (20:54 -0600)
debian/rules
dtools/bin/extract_install_filenames [new file with mode: 0755]

index d7d8a85bae15ef1fa4d0d6b3d6290633cfa52b0e..4355cc982fd68860a03ce6f9f90f0d37ab508041 100755 (executable)
@@ -62,7 +62,8 @@ build-stamp: configure-stamp
 extract: extract-stamp
 extract-stamp: build-stamp debian/gen-install-files.sh
        dh_testdir
-       sh debian/gen-install-files.sh
+       chmod +x debian/gen-install-files.sh dtools/bin/extract_install_filenames
+       debian/gen-install-files.sh
        touch $@
 
 install: install-stamp
diff --git a/dtools/bin/extract_install_filenames b/dtools/bin/extract_install_filenames
new file mode 100755 (executable)
index 0000000..8ffce9d
--- /dev/null
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+
+"""
+Example usage:
+
+  $ extract_install_filenames gnuradio-core/src/lib/swig/Makefile grgrpython_PYTHON
+
+Produces:
+
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_python.py
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_py_runtime.py
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_py_general.py
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_py_gengen.py
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_py_filter.py
+  usr/local/lib64/python2.4/site-packages/gnuradio/gr/gnuradio_swig_py_io.py
+
+"""
+
+from optparse import OptionParser
+import re
+import sys
+import tempfile
+import os
+
+def make_makefile_tail(dirname, full_var_name):
+    
+    s = '''
+extract_install_filenames:
+       @echo $(%s)
+       @echo $(%s)
+
+''' % (dirname, full_var_name)
+    return s
+
+
+def main():
+    parser = OptionParser(usage="usage: %prog [options] Makefile AM-variable-name")
+    (options, args) = parser.parse_args()
+    if len(args) != 2:
+        parser.print_help()
+        raise SystemExit
+
+    makefile_name = args[0]
+    makefile = open(makefile_name, 'r')
+    full_var_name = args[1]
+
+    L = re.split('_', full_var_name)
+    prefix = '_'.join(L[:-1])
+    suffix = L[-1]
+
+    #print "prefix= ", prefix
+    #print "suffix= ", suffix
+
+    if suffix.upper() != suffix:
+        raise SystemExit, "AM-variable-name is malformed.  Expected something like grgrpython_PYTHON"
+
+    if prefix[:5] == "dist_":
+        dirname = prefix[5:] + "dir"
+    else:
+        dirname = prefix + "dir"
+    #print "dirname =", dirname
+
+    tail = make_makefile_tail(dirname, full_var_name)
+
+    tmp_makefile = tempfile.NamedTemporaryFile()
+    #print "tmp_makefile =", tmp_makefile
+    tmp_name = tmp_makefile.name
+    #print "tmp_name =", tmp_name
+    s = makefile.read()
+    tmp_makefile.write(s)
+    tmp_makefile.write(tail)
+    tmp_makefile.flush()
+
+    (head, tail) = os.path.split(makefile_name)
+    if head:
+        # cd to directory that contained the original Makefile
+        cmd = 'cd %s; make -s -f %s extract_install_filenames' % (head, tmp_name)
+    else:
+        cmd = 'make -s -f %s extract_install_filenames' % (tmp_name,)
+        
+    #print "cmd =", cmd
+    make = os.popen(cmd, 'r')
+    target_dirname = make.readline().rstrip()
+    target_files = make.readline().rstrip()
+    if target_dirname.startswith('/'):
+        target_dirname = target_dirname[1:]
+   
+    #print "target_dirname =", target_dirname
+    #print "target_files =", target_files
+
+    for f in target_files.split():
+        sys.stdout.write(os.path.join(target_dirname, f.split('/')[-1]) + '\n')
+
+if __name__ == '__main__':
+  main()
+
+
+