home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / man / man1 / pkg-config.1 < prev    next >
Encoding:
Text File  |  2008-04-09  |  15.4 KB  |  439 lines

  1. .\" 
  2. .\" pkg-config manual page.
  3. .\" (C) Red Hat, Inc. based on gnome-config man page (C) Miguel de Icaza (miguel@gnu.org)
  4. .\"
  5. .
  6. .\" Macros to disable groff line adjustment warnings that we can't easily
  7. .\" fix in the text.
  8. .ie \n(.g \{\
  9. .  de DW
  10. .    nr .oldwarn \n[.warn]
  11. .    warn 0
  12. .  .
  13. .  de EW
  14. .    warn \n[.oldwarn]
  15. .  .
  16. .\}
  17. .el \
  18. .\{ \
  19. .  de DW
  20. .  .
  21. .  de EW
  22. .  .
  23. .\}
  24. .
  25. .TH pkg-config 1
  26. .SH NAME
  27. pkg-config \- Return metainformation about installed libraries
  28. .SH SYNOPSIS
  29. .PP
  30. .B pkg-config
  31. [\-\-modversion] [\-\-help] [\-\-print-errors] [\-\-silence-errors] 
  32. [\-\-cflags] [\-\-libs] [\-\-libs-only-L]
  33. [\-\-libs-only-l] [\-\-cflags-only-I]
  34. [\-\-variable=VARIABLENAME]
  35. [\-\-define-variable=VARIABLENAME=VARIABLEVALUE]
  36. [\-\-uninstalled]
  37. [\-\-exists] [\-\-atleast-version=VERSION] [\-\-exact-version=VERSION]
  38. [\-\-max-version=VERSION] [LIBRARIES...]
  39. .SH DESCRIPTION
  40.  
  41. The \fIpkg-config\fP program is used to retrieve information about
  42. installed libraries in the system.  It is typically used to compile
  43. and link against one or more libraries.  Here is a typical usage
  44. scenario in a Makefile:
  45. .PP
  46. .nf
  47. program: program.c
  48.     cc program.c `pkg-config --cflags --libs gnomeui`
  49. .fi
  50. .PP
  51.  
  52. .PP
  53. \fIpkg-config\fP retrieves information about packages from 
  54. special metadata files. These files are named after the package, 
  55. with the extension \fI.pc\fP. By default, pkg-config looks in 
  56. the directory \fIprefix\fP/lib/pkgconfig for these files; it will also
  57. look in the colon-separated (on Windows, semicolon-separated) 
  58. list of directories specified by the 
  59. PKG_CONFIG_PATH environment variable. 
  60.  
  61. .PP
  62. The package name specified on the \fIpkg-config\fP command line is
  63. defined to be the name of the metadata file, minus the \fI.pc\fP
  64. extension. If a library can install multiple versions simultaneously,
  65. it must give each version its own name (for example, GTK 1.2 might
  66. have the package name "gtk+" while GTK 2.0 has "gtk+-2.0").
  67.  
  68. .SH OPTIONS
  69. The following options are supported:
  70. .TP
  71. .I "--modversion"
  72. Requests that the version information of the libraries specified on
  73. the command line be displayed.  If \fIpkg-config\fP can find all the
  74. libraries on the command line, each library's version string is
  75. printed to stdout, one version per line. In this case \fIpkg-config\fP
  76. exits successfully. If one or more libraries is unknown,
  77. \fIpkg-config\fP exits with a nonzero code, and the contents of stdout
  78. are undefined.
  79. .TP
  80. .I "--help"
  81. Displays a help message and terminates.
  82.  
  83. .TP
  84. .I "--print-errors"
  85. If one or more of the modules on the command line, or their
  86. dependencies, are not found, or if an error occurs in parsing
  87. a \fI.pc\fP file, then this option will cause errors explaining the
  88. problem to be printed. With "predicate" options such as "--exists"
  89. \fIpkg-config\fP runs silently by default, because it's usually used
  90. in scripts that want to control what's output. This option can be used
  91. alone (to just print errors encountered locating modules on the 
  92. command line) or with other options. The PKG_CONFIG_DEBUG_SPEW
  93. environment variable overrides this option.
  94.  
  95. .TP
  96. .I "--silence-errors"
  97. If one or more of the modules on the command line, or their
  98. dependencies, are not found, or if an error occurs in parsing a
  99. a \fI.pc\fP file, then this option will keep errors explaining the
  100. problem from being printed. With "predicate" options such as
  101. "--exists" \fIpkg-config\fP runs silently by default, because it's
  102. usually used in scripts that want to control what's output. So this
  103. option is only useful with options such as "--cflags" or
  104. "--modversion" that print errors by default. The PKG_CONFIG_DEBUG_SPEW
  105. environment variable overrides this option.
  106.  
  107. .TP
  108. .I "--errors-to-stdout"
  109. If printing errors, print them to stdout rather than the default stderr
  110.  
  111. .PP
  112. The following options are used to compile and link programs:
  113. .TP
  114. .I "--cflags"
  115. This prints pre-processor and compile flags required to compile the
  116. packages on the command line, including flags for all their
  117. dependencies. Flags are "compressed" so that each identical flag
  118. appears only once. \fIpkg-config\fP exits with a nonzero code if it
  119. can't find metadata for one or more of the packages on the command
  120. line.
  121. .TP 
  122. .I "--libs"
  123. This option is identical to "--cflags", only it prints the link
  124. flags. As with "--cflags", duplicate flags are merged (maintaining
  125. proper ordering), and flags for dependencies are included in the
  126. output.
  127. .TP
  128. .I "--libs-only-L"
  129. This prints the -L/-R part of "--libs". That is, it defines the 
  130. library search path but doesn't specify which libraries to link with.
  131. .TP
  132. .I "--libs-only-l"
  133. This prints the -l part of "--libs" for the libraries specified on
  134. the command line. Note that the union of "--libs-only-l" and
  135. "--libs-only-L" may be smaller than "--libs", due to flags such as
  136. -rdynamic.
  137.  
  138. .TP
  139. .I "--variable=VARIABLENAME"
  140. This returns the value of a variable defined in a package's \fI.pc\fP
  141. file. Most packages define the variable "prefix", for example, so you 
  142. can say:
  143. .nf
  144.   $ pkg-config --variable=prefix glib-2.0
  145.   /usr/
  146. .fi
  147. .TP
  148. .I "--define-variable=VARIABLENAME=VARIABLEVALUE"
  149. This sets a global value for a variable, overriding the value in any
  150. \fI.pc\fP files. Most packages define the variable "prefix", for
  151. example, so you can say:
  152. .nf
  153.   $ pkg-config --print-errors --define-variable=prefix=/foo \e
  154.                --variable=prefix glib-2.0
  155.   /foo
  156. .fi
  157.  
  158. .TP
  159. .I "--uninstalled"
  160. Normally if you request the package "foo" and the package
  161. "foo-uninstalled" exists, \fIpkg-config\fP will prefer the 
  162. "-uninstalled" variant. This allows compilation/linking against
  163. uninstalled packages. If you specify the "--uninstalled" option,
  164. \fIpkg-config\fP will return successfully if any "-uninstalled"
  165. packages are being used, and return failure (false) otherwise.
  166. (The "PKG_CONFIG_DISABLE_UNINSTALLED" environment variable keeps 
  167. \fIpkg-config\fP from implicitly choosing "-uninstalled" packages, so
  168. if that variable is set, they will only have been used if you pass 
  169. a name like "foo-uninstalled" on the command line explicitly.)
  170.  
  171. .TP
  172. .I "--exists"
  173. .TP
  174. .I "--atleast-version=VERSION"
  175. .TP
  176. .I "--exact-version=VERSION"
  177. .TP
  178. .I "--max-version=VERSION"
  179. These options test whether the package or list of packages on the
  180. command line are known to \fIpkg-config\fP, and optionally 
  181. whether the version number of a package meets certain contraints.
  182. If all packages exist and meet the specified version constraints,
  183. \fIpkg-config\fP exits successfully. Otherwise it exits unsuccessfully.
  184.  
  185. Rather than using the version-test options, you can simply give a version
  186. constraint after each package name, for example:
  187. .nf
  188.   $ pkg-config --exists 'glib-2.0 >= 1.3.4 libxml = 1.8.3'
  189. .fi
  190. Remember to use \-\-print-errors if you want error messages.
  191.  
  192. .TP
  193. .I "--msvc-syntax"
  194. This option is available only on Windows. It causes \fIpkg-config\fP
  195. to output -l and -L flags in the form recognized by the Microsoft
  196. Visual C++ command-line compiler, \fIcl\fP. Specifically, instead of
  197. \fI-Lx:/some/path\fP it prints \fI/libpath:x/some/path\fP, and instead
  198. of \fI-lfoo\fP it prints \fIfoo.lib\fP. Note that the --libs output
  199. consists of flags for the linker, and should be placed on the cl
  200. command line after a /link switch. 
  201.  
  202. .TP
  203. .I "--dont-define-prefix"
  204. This option is available only on Windows. It prevents \fIpkg-config\fP
  205. from automatically trying to override the value of the variable
  206. "prefix" in each .pc file.
  207.  
  208. .TP
  209. .I "--prefix-variable=PREFIX"
  210. Also this option is available only on Windows. It sets the name of the
  211. variable that \fIpkg-config\fP automatically sets as described above.
  212.  
  213. .TP
  214. .I "--static"
  215. Output libraries suitable for static linking.  That means including
  216. any private libraries in the output.  This relies on proper tagging in
  217. the .pc files, else a too large number of libraries will ordinarily be
  218. output.
  219.  
  220. .SH ENVIRONMENT VARIABLES
  221.  
  222. .TP
  223. .I "PKG_CONFIG_PATH"
  224. A colon-separated (on Windows, semicolon-separated) list of
  225. directories to search for .pc files.  The default directory will
  226. always be searched after searching the path; the default is
  227. \fIlibdir\fP/pkgconfig:\fIdatadir\fP/pkgconfig where \fIlibdir\fP is
  228. the libdir where \fIpkg-config\fP and \fIdatadir\fP is the datadir
  229. where \fIpkg-config\fP was installed.
  230.  
  231. .TP
  232. .I "PKG_CONFIG_DEBUG_SPEW"
  233. If set, causes \fIpkg-config\fP to print all kinds of
  234. debugging information and report all errors.
  235.  
  236. .TP
  237. .I "PKG_CONFIG_TOP_BUILD_DIR"
  238. A value to set for the magic variable \fIpc_top_builddir\fP
  239. which may appear in \fI.pc\fP files. If the environment variable is
  240. not set, the default value '$(top_builddir)' will be used. This
  241. variable should refer to the top builddir of the Makefile where the 
  242. compile/link flags reported by \fIpkg-config\fP will be used.
  243. This only matters when compiling/linking against a package that hasn't
  244. yet been installed.
  245.  
  246. .TP
  247. .I "PKG_CONFIG_DISABLE_UNINSTALLED"
  248. Normally if you request the package "foo" and the package
  249. "foo-uninstalled" exists, \fIpkg-config\fP will prefer the 
  250. "-uninstalled" variant. This allows compilation/linking against
  251. uninstalled packages.  If this environment variable is set, it
  252. disables said behavior.
  253.  
  254. .TP
  255. .I "PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"
  256. Don't strip -I/usr/include out of cflags.
  257.  
  258. .TP
  259. .I "PKG_CONFIG_ALLOW_SYSTEM_LIBS"
  260. Don't strip -L/usr/lib out of libs
  261.  
  262. .TP
  263. .I "PKG_CONFIG_SYSROOT_DIR"
  264. Modify -I and -L to use the directories located in target sysroot.
  265. this option is usefull when crosscompiling package that use pkg-config
  266. to determine CFLAGS anf LDFLAGS. -I and -L are modified to point to 
  267. the new system root. this means that a -I/usr/include/libfoo will
  268. become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR
  269. equal to /var/target (same rule apply to -L)
  270.  
  271. .TP
  272. .I "PKG_CONFIG_LIBDIR"
  273. Replaces the default \fIpkg-config\fP search directory.
  274.  
  275. .SH WINDOWS SPECIALITIES
  276. If a .pc file is found in a directory that matches the usual
  277. conventions (i.e., ends with \\lib\\pkgconfig), the prefix for that
  278. package is assumed to be the grandparent of the directory where the
  279. file was found, and the \fIprefix\fP variable is overridden for that
  280. file accordingly.
  281.  
  282. In addition to the \fIPKG_CONFIG_PATH\fP environment variable, the
  283. Registry keys
  284. .DW
  285. \fIHKEY_CURRENT_USER\\Software\\pkgconfig\\PKG_CONFIG_PATH\fP and
  286. .EW
  287. \fIHKEY_LOCAL_MACHINE\\Software\\pkgconfig\\PKG_CONFIG_PATH\fP can be
  288. used to specify directories to search for .pc files. Each (string)
  289. value in these keys is treated as a directory where to look for .pc
  290. files.
  291.  
  292. .SH AUTOCONF MACROS
  293.  
  294. .TP
  295. .I "PKG_CHECK_MODULES(VARIABLE-PREFIX,MODULES[,ACTION-IF-FOUND,[ACTION-IF-NOT-FOUND]])"
  296.  
  297. The macro PKG_CHECK_MODULES can be used in \fIconfigure.ac\fP to 
  298. check whether modules exist. A typical usage would be:
  299. .nf
  300.  PKG_CHECK_MODULES([MYSTUFF], [gtk+-2.0 >= 1.3.5 libxml = 1.8.4])
  301. .fi
  302.  
  303. This would result in MYSTUFF_LIBS and MYSTUFF_CFLAGS substitution
  304. variables, set to the libs and cflags for the given module list. 
  305. If a module is missing or has the wrong version, by default configure
  306. will abort with a message. To replace the default action, 
  307. specify an ACTION-IF-NOT-FOUND. PKG_CHECK_MODULES will not print any
  308. error messages if you specify your own ACTION-IF-NOT-FOUND.
  309. However, it will set the variable MYSTUFF_PKG_ERRORS, which you can 
  310. use to display what went wrong.
  311.  
  312. Note that if there is a possibility the first call to
  313. PKG_CHECK_MODULES might not happen, you should be sure to include an
  314. explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
  315.  
  316. .I "PKG_PROG_PKG_CONFIG([MIN-VERSION])"
  317.  
  318. Defines the PKG_CONFIG variable to the best pkg-config available,
  319. useful if you need pkg-config but don't want to use PKG_CHECK_MODULES.
  320.  
  321. .I "PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])"
  322.  
  323. Check to see whether a particular set of modules exists.  Similar
  324. to PKG_CHECK_MODULES(), but does not set variables or print errors.
  325.  
  326. Similar to PKG_CHECK_MODULES, make sure that the first instance of
  327. this or PKG_CHECK_MODULES is called, or make sure to call
  328. PKG_CHECK_EXISTS manually
  329.  
  330. .SH METADATA FILE SYNTAX
  331. To add a library to the set of packages \fIpkg-config\fP knows about,
  332. simply install a \fI.pc\fP file. You should install this file to 
  333. \fIlibdir\fP/pkgconfig.
  334.  
  335. .PP
  336. Here is an example file:
  337. .nf
  338. # This is a comment
  339. prefix=/home/hp/unst   # this defines a variable
  340. exec_prefix=${prefix}  # defining another variable in terms of the first
  341. libdir=${exec_prefix}/lib
  342. includedir=${prefix}/include
  343.  
  344. Name: GObject                            # human-readable name
  345. Description: Object/type system for GLib # human-readable description
  346. Version: 1.3.1
  347. URL: http://www.gtk.org
  348. Requires: glib-2.0 = 1.3.1
  349. Conflicts: foobar <= 4.5
  350. Libs: -L${libdir} -lgobject-1.3
  351. Libs.private: -lm
  352. Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib/include 
  353. .fi
  354.  
  355. .PP
  356. You would normally generate the file using configure, of course, so
  357. that the prefix, etc. are set to the proper values.
  358.  
  359. .PP
  360. Files have two kinds of line: keyword lines start with a keyword plus
  361. a colon, and variable definitions start with an alphanumeric string
  362. plus an equals sign. Keywords are defined in advance and have special
  363. meaning to \fIpkg-config\fP; variables do not, you can have any
  364. variables that you wish (however, users may expect to retrieve the
  365. usual directory name variables).
  366.  
  367. .PP
  368. Note that variable references are written "${foo}"; you can escape
  369. literal "${" as "$${".
  370.  
  371. .TP
  372. .I "Name:"
  373. This field should be a human-readable name for the package. Note that
  374. it is not the name passed as an argument to \fIpkg-config\fP.
  375. .TP
  376. .I "Description:"
  377. This should be a brief description of the package
  378. .TP
  379. .I "URL:"
  380. An URL where people can get more information about and download the package
  381. .TP
  382. .I "Version:"
  383. This should be the most-specific-possible package version string.
  384. .TP
  385. .I "Requires:"
  386. This is a comma-separated list of packages that are required by your
  387. package. Flags from dependent packages will be merged in to the flags
  388. reported for your package. Optionally, you can specify the version 
  389. of the required package (using the operators =, <, >, >=, <=);
  390. specifying a version allows \fIpkg-config\fP to perform extra sanity
  391. checks. You may only mention the same package one time on the 
  392. .I "Requires:"
  393. line. If the version of a package is unspecified, any version will
  394. be used with no checking.
  395. .TP
  396. .I "Conflicts:"
  397. This optional line allows \fIpkg-config\fP to perform additional
  398. sanity checks, primarily to detect broken user installations.  The
  399. syntax is the same as
  400. .I "Requires:"
  401. except that
  402. you can list the same package more than once here, for example 
  403. "foobar = 1.2.3, foobar = 1.2.5, foobar >= 1.3", if you have reason to
  404. do so. If a version isn't specified, then your package conflicts with
  405. all versions of the mentioned package. 
  406. If a user tries to use your package and a conflicting package at the
  407. same time, then \fIpkg-config\fP will complain.
  408. .TP
  409. .I "Libs:"
  410. This line should give the link flags specific to your package. 
  411. Don't add any flags for required packages; \fIpkg-config\fP will 
  412. add those automatically.
  413.  
  414. .TP
  415. .I "Libs.private:"
  416. This line should list any private libraries in use.  Private libraries
  417. are libraries which are not exposed through your library, but are
  418. needed in the case of static linking.
  419.  
  420. .TP
  421. .I "Cflags:"
  422. This line should list the compile flags specific to your package. 
  423. Don't add any flags for required packages; \fIpkg-config\fP will 
  424. add those automatically.
  425.  
  426. .SH AUTHOR
  427.  
  428. \fIpkg-config\fP was written by James Henstridge, rewritten by Martijn
  429. van Beers, and rewritten again by Havoc Pennington. Tim Janik, Owen
  430. Taylor, and Raja Harinath submitted suggestions and some code.
  431. \fIgnome-config\fP was written by Miguel de Icaza, Raja Harinath and
  432. various hackers in the GNOME team.  It was inspired by Owen Taylor's
  433. \fIgtk-config\fP program.
  434.  
  435. .SH BUGS
  436.  
  437. \fIpkg-config\fP does not handle mixing of parameters with and without
  438. = well.  Stick with one.
  439.