File: depend.py

package info (click to toggle)
psyco-doc 1.6-1
  • links: PTS
  • area: contrib
  • in suites: lenny
  • size: 1,832 kB
  • ctags: 3,236
  • sloc: ansic: 23,895; python: 5,646; perl: 1,309; makefile: 153
file content (44 lines) | stat: -rw-r--r-- 1,080 bytes parent folder | download | duplicates (7)
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
import os, sys, files
from mkincl import *

GCC = '/usr/bin/gcc'

processor = sys.argv[1]


g = open('dyn-Makefile', 'w')
print >> g, "# automatically generated by depend.py"
print >> g
print >> g, "O_FILES =",

basenames = []
for f in files.SRC:
    assert f.filename.endswith('.c')
    basenames.append(f.filename[:-2])
for f in files.PROCESSOR_SRC[processor]:
    assert f.filename.endswith('.c')
    basenames.append(processor + '/' + f.filename[:-2])

for fn in basenames:
    print >> g, fn+'.o',
print >> g
print >> g

for fn in basenames:
    print fn
    h = os.popen("%s -I%s %s -M -Wundef %s.c" % (GCC, processor,
                                                  INCLUDE_STR, fn), 'r')
    data = h.read()
    h.close()
    data = data.replace('\\\n', ' ')
    data = data[data.index(':')+1:]
    data = data.strip().split()
    data = map(os.path.normpath, data)
    found = {}
    print >> g, '%s.o:' % fn,
    for f1 in data:
        if f1 not in found and not f1.startswith('/'):
            print >> g, f1,
            found[f1] = 1
    print >> g
    print >> g