1.Dd November 14, 2012 
2.Os Darwin
3.Dt KEXTLIBS 8
4.Sh NAME
5.Nm kextlibs
6.Nd find OSBundleLibraries needed by a kext
7.Sh SYNOPSIS
8.Nm
9.Op Ar options
10.Op Fl -
11.Ar kext Li \&.\|.\|.
12.Sh DESCRIPTION
13The
14.Nm
15utility searches for library kexts that define symbols
16needed for linking by
17.Ar kext ,
18printing their bundle identifiers and versions to
19.Pa stdout .
20If the kext has a multiple-architecture executable,
21libraries are resolved for each architecture.
22If any symbols are not found, or are found in multiple libraries,
23the numbers of such symbols are printed to standard error
24after the library kext information for each architecture.
25.Pp
26A handy use of
27.Nm
28is to run it with just the
29.Fl xml
30flag and pipe the output to
31.Xr pbcopy(1) ;
32if the exit status is zero
33(indicating no undefined or multiply-defined symbols),
34you can open your kext's
35.Pa Info.plist
36file in a text editor
37and paste the library declarations over the OSBundleLibraries property.
38.Pp
39You can use
40.Nm
41to find libraries for older releases of Mac OS X
42using the
43.Fl repository
44option to specify an extensions folder to search
45other than the extensions directories for the root volume
46(although releases prior to Mac OS X 10.6 (Snow Leopard)
47don't check for architecture-specific properties,
48so be sure to check the output and edit as needed).
49If you don't explicitly specify a repository directory,
50.Nm
51searches the root volume's /System/Library/Extensions and /Library/Extensions directories.
52.Sh OPTIONS
53.Bl -tag -width -indent
54.It Fl h , help
55Print a help message describing each option flag and exit with a success result,
56regardless of any other options on the command line.
57.It Fl all-symbols
58Print reports on all symbols that remain undefined,
59all symbols that have been resolved in one library kext each,
60and all symbols that have multiple definitions in different library kexts.
61Equivalent to specifying all of
62.Fl undef-symbols ,
63.Fl onedef-symbols ,
64and
65.Fl multdef-symbols .
66Normally only the number of missing and duplicate symbols is printed.
67.It Fl c , Fl compatible-versions
68Print the compatible version rather than the current version.
69.It Fl multdef-symbols
70Print all undefined symbols from
71.Ar kext
72found in more than one library kext,
73followed by those library kexts' bundle identifiers
74and versions (or compatible versions if
75.Fl compatible-versions
76was specified).
77Normally only the number of multiply-defined symbols is printed.
78.It Fl non-kpi
79Search the compatibility kext, com.apple.kernel.6.0,
80rather than any of the com.apple.kpi.* system kexts.
81Use of this option is not recommended:
82The exact kernel component (mach, bsd, libkern, or iokit)
83cannot be determined,
84and the compatible version of com.apple.kernel
85is locked to its current version,
86so kexts linking against it can only load against that exact version.
87.It Fl onedef-symbols
88Print all undefined symbols from
89.Ar kext
90found in exactly one library kext,
91followed by that library kext's bundle identifier
92and version (or compatible version if
93.Fl compatible-versions
94was specified).
95Normally nothing is printed about symbols that are found once.
96.It Fl r Ar directory , Fl repository Ar directory
97Search
98.Ar directory
99for dependencies.
100This option may be specified multiple times.
101You can use this to get library declarations
102relative to a set of extensions other than those of the running system
103(such as for a different release of Mac OS X),
104or to include a side directory of library kexts.
105Note: If you specify a directory with this option,
106the system extensions folders are not implicitly searched.
107See
108.Fl system-extensions .
109.It Fl e , Fl system-extensions
110Add /System/Library/Extensions and /Library/Extensions to the list of directories to search.
111If you don't specify any directories or kexts, this is used by default.
112.It Fl undef-symbols
113Print all undefined symbols from
114.Ar kext
115that can't be found in any library kexts.
116Normally only the number of symbols not found is printed.
117.It Fl unsupported
118Search unsupported library kexts for symbols (by default they are not searched).
119.It Fl v Li [ 0-6 | 0x#### Ns Li ] , Fl verbose Li [ 0-6 | 0x#### Ns Li ]
120Verbose mode; print information about program operation.
121Higher levels of verbosity include all lower levels.
122You can specify a level from 0-6,
123or a hexadecimal log specification
124(as described in
125.Xr kext_logging 8 Ns No ).
126For
127.Nm ,
128the decimal levels 1-6 generally have little effect.
129.It Fl xml
130Print an XML fragment to
131.Pa stdout
132suitable for copying and pasting directly
133into an
134.Pa Info.plist
135file.
136This option prints
137information about libraries to
138.Pa stdout ,
139and then prints
140information
141about symbols to
142.Pa stderr.
143In XML mode, if the libraries for all architectures
144are the same, only one set of OSBundleLibraries is printed;
145if any differ from any others,
146architecture-specific listings for all architectures are printed
147(OSBundleLibraries_i386, OSBundleLibraries_x86_64, and so on).
148.Pp
149.It Fl -
150End of options.
151.El
152.Sh FILES
153.Bl -tag -width "/System/Library/Extensions/" -compact
154.It Pa /System/Library/Extensions/
155The standard system repository of kernel extensions.
156.It Pa /Library/Extensions/
157The standard repository of non Apple kernel extensions.
158.El
159.Sh DIAGNOSTICS
160The
161.Nm
162utility exits with a status of 0 on completion
163if all undefined symbols are found exactly once;
164with a status of 1 if any undefined symbols remain,
165or with a status of 2 if any symbols
166are found in more than one library kext
167(whether or not any undefined symbols remain),
168and with another nonzero status on some other problem.
169.Sh BUGS
170.Nm
171uses a simple algorithm of string matching to resolve symbols,
172and does not apply any of the patching that the full link process does.
173This can cause it to fail when searching for symbols
174in a kext built against an SDK for a prior release of Mac OS X
175than the one on which
176.Nm
177is being used.
178In such cases, you can run
179.Nm
180against the Extensions folder of that prior release
181using the
182.Fl repository
183option.
184.Pp
185Many single-letter options are inconsistent in meaning
186with (or directly contradictory to) the same letter options
187in other kext tools.
188.Sh SEE ALSO
189.Xr kextutil 8 ,
190.Xr kextfind 8 ,
191.Xr kext_logging 8
192