File: mkc_get_deps.in

package info (click to toggle)
mk-configure 0.36.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,996 kB
  • sloc: ansic: 4,974; makefile: 1,387; sh: 1,087; cpp: 177; perl: 101; yacc: 85; lex: 21
file content (43 lines) | stat: -rwxr-xr-x 719 bytes parent folder | download | duplicates (4)
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
#!@AWK@ -f

# Usage: mkc_get_deps
# $1 -- project name
# ENVIRON ["AXCIENT_LIBDEPS"] -- dep1:prj1 dep2:prj2 ...

function print_all_deps (prj,             i,next_prj){
	if (prj in processed)
		return

	processed [prj]=1

	for (i=1; i <= count [prj]; ++i){
		next_prj = graph[prj, i]
		print_all_deps(next_prj)
	}

	if (topprj != prj)
		result [++result_sz] = prj
}

BEGIN {
	topprj = ARGV [1]
	if (!topprj)
		exit(10)

	cnt = split(ENVIRON ["AXCIENT_LIBDEPS"], deps, / +|:/)
	if (int(cnt/2)*2 != cnt)
		exit(11)

	for (i=1; i <= cnt; i += 2){
		from = deps [i]
		to   = deps [i+1]
		graph[to, ++count [to]] = from
	}

	print_all_deps(topprj)

	for (i=result_sz; i >= 1; --i)
		print result [i]

	print "" # for bmake
}