summaryrefslogtreecommitdiff
path: root/scripts/rsp.awk
blob: d157e249317a02f210b685ede9d64d04c1dc5312 (plain)
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
function line() {
	if (match($0, /\.d$/))
		read($0)
	else
		libs[++n] = $0
}

function read(name) {
	for (;;) {
		ret = getline < name
		if (ret < 0) {
			print "failed to read line from " name > "/proc/self/fd/2"
			exit(1)
		}
		if (ret == 0)
			break
		line()
	}
	close(name)
}

{line()}

END {
	for (i = n; i > 0; --i) {
		lib = libs[i]
		if (lib in seen)
			continue
		seen[lib] = 1
		uniq[++m] = lib
	}
	for (i = m; i > 0; --i)
		print uniq[i]
}