Thu Jun 7 04:58:46 2018 UTC ()
check-shlibs-macho.awk: fix support for checking modules

Allow the dylib install_name to be just the library basename


(dbj)
diff -r1.5 -r1.6 pkgsrc/mk/check/check-shlibs-macho.awk

cvs diff -r1.5 -r1.6 pkgsrc/mk/check/check-shlibs-macho.awk (expand / switch to unified diff)

--- pkgsrc/mk/check/check-shlibs-macho.awk 2018/05/25 10:57:28 1.5
+++ pkgsrc/mk/check/check-shlibs-macho.awk 2018/06/07 04:58:46 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: check-shlibs-macho.awk,v 1.5 2018/05/25 10:57:28 jperkin Exp $ 1# $NetBSD: check-shlibs-macho.awk,v 1.6 2018/06/07 04:58:46 dbj Exp $
2 2
3# 3#
4# Read a list of potential Mach-O binaries from stdin. 4# Read a list of potential Mach-O binaries from stdin.
5# For each, check the list of required DSOs and ensure that each of them can 5# For each, check the list of required DSOs and ensure that each of them can
6# be found correctly, and check that any pkgsrc-installed DSOs belong to a 6# be found correctly, and check that any pkgsrc-installed DSOs belong to a
7# full dependency. 7# full dependency.
8# 8#
9 9
10function shquote(IN, out) { 10function shquote(IN, out) {
11 out = IN; 11 out = IN;
12 gsub("\\\\", "\\\\", out); 12 gsub("\\\\", "\\\\", out);
13 gsub("\\\n", "\\n", out); 13 gsub("\\\n", "\\n", out);
14 gsub("\\\t", "\\t", out); 14 gsub("\\\t", "\\t", out);
@@ -60,29 +60,38 @@ function check_pkg(DSO, pkg, found) { @@ -60,29 +60,38 @@ function check_pkg(DSO, pkg, found) {
60 if ($1 != "full") 60 if ($1 != "full")
61 continue 61 continue
62 close(depends_file) 62 close(depends_file)
63 return 0 63 return 0
64 } 64 }
65 } 65 }
66 if (found) 66 if (found)
67 print DSO ": " pkg " is not a runtime dependency" 67 print DSO ": " pkg " is not a runtime dependency"
68 close(depends_file) 68 close(depends_file)
69} 69}
70 70
71function checkshlib(DSO, needed, found) { 71function checkshlib(DSO, needed, found) {
72 cmd = "otool -XL " shquote(DSO) " 2>/dev/null" 72 cmd = "otool -XL " shquote(DSO) " 2>/dev/null"
 73 libno = 0
73 while ((cmd | getline) > 0) { 74 while ((cmd | getline) > 0) {
74 if ($0 !~ /^\t/) 75 if ($0 !~ /^\t/)
75 continue 76 continue
 77 #
 78 # The first lib is the "install_name". Allow it to
 79 # be just the library basename name to support modules.
 80 #
 81 if (libno++ == 0 &&
 82 $1 == parts[split(DSO, parts, "/")]) {
 83 continue
 84 }
76 needed[$1] = "" 85 needed[$1] = ""
77 } 86 }
78 close(cmd) 87 close(cmd)
79 ndirs = split(cross_destdir ":" destdir, check_dirs, ":") 88 ndirs = split(cross_destdir ":" destdir, check_dirs, ":")
80 for (lib in needed) { 89 for (lib in needed) {
81 # 90 #
82 # Ensure we don't have any WRKDIR references. 91 # Ensure we don't have any WRKDIR references.
83 # 92 #
84 if (lib == wrkdir || 93 if (lib == wrkdir ||
85 substr(lib, 1, length(wrkdir) + 1) == wrkdir "/") 94 substr(lib, 1, length(wrkdir) + 1) == wrkdir "/")
86 print DSO ": path relative to WRKDIR: " lib 95 print DSO ": path relative to WRKDIR: " lib
87 96
88 # 97 #