summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdtools/bin/extract_install_filenames94
1 files changed, 94 insertions, 0 deletions
diff --git a/dtools/bin/extract_install_filenames b/dtools/bin/extract_install_filenames
new file mode 100755
index 000000000..c4936053c
--- /dev/null
+++ b/dtools/bin/extract_install_filenames
@@ -0,0 +1,94 @@
+#!/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"
+
+ dirname = prefix + "dir"
+
+ 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 -f %s extract_install_filenames' % (head, tmp_name)
+ else:
+ cmd = 'make -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) + '\n')
+
+if __name__ == '__main__':
+ main()
+
+
+