-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmakedepends
executable file
·38 lines (31 loc) · 1.2 KB
/
makedepends
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
#!/usr/bin/env python
import os, sys, re
incre = re.compile(r'# *include *"(.+\.h)"')
dep = open('depends', 'w')
ignored_headers = ('zlib.h', 'OpenMM.h', 'netcdf.h')
for f in os.listdir('.'):
if f.endswith('.F90') or f.endswith('.cpp'):
if f in ignored_headers: continue
mydep = [f]
fd = open(f, 'r')
for line in fd:
if incre.match(line):
d = incre.match(line).groups()[0]
if not d in mydep and not d in ignored_headers:
mydep.append('../include/%s' % d)
if mydep: dep.write('%s: %s\n' % (f.replace('.cpp', '.o').replace('.F90', '.o'), ' '.join(mydep)))
for f in os.listdir('../include/amber') + ['Amber.h']:
if f in ignored_headers: continue
mydep = []
if f == 'Amber.h':
f = os.path.join('..', 'include', f)
else:
f = os.path.join('..', 'include', 'amber', f)
fd = open(f, 'r')
for line in fd:
if incre.match(line):
d = incre.match(line).groups()[0]
if not d in mydep and not d in ignored_headers:
mydep.append('../include/amber/%s' % os.path.split(d)[1])
if mydep: dep.write('%s: %s\n' % (f, ' '.join(mydep)))
dep.close()