summaryrefslogtreecommitdiff
path: root/mk/configure/cmake-rewrite.awk
blob: d74b35ad38fa312b1d27ae0dc61ea54c1a89b7b9 (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
# $NetBSD: cmake-rewrite.awk,v 1.2 2007/12/20 18:51:18 abs Exp $
#
# cleanup references to libraries in the buildlink tree in files
# written by cmake's  export_library_dependencies() function
#
BEGIN { buildlink_dir = ARGV[1]; delete ARGV[1] }
{ 
    match($0, "_LIB_DEPENDS \"")
    if (RSTART == 0) {
	print
    } else {
	printf "%s \"", $1
	d=substr($0,RSTART+RLENGTH,length($0))
	while ( d != "\")") {
	    match(d,"[^;]*")
	    dep=substr(d,RSTART,RLENGTH)
	    d=substr(d,RLENGTH+2,length(d))
	    if (dep ~ "^" buildlink_dir) {
		"ls -l " dep | getline  ls_out
		close ("ls -l " dep)
		match(ls_out,"-> ")
		if (RSTART > 0) {
		    dep=substr(ls_out,RSTART+RLENGTH,length(ls_out))
		}
	    }
	    printf "%s;",dep
	}
	print d
    }
}