pg_config — retrieve information about the installed version of PostgreSQL
pg_config [option...]
The pg_config utility prints configuration parameters of the currently installed version of PostgreSQL. It is intended, for example, to be used by software packages that want to interface to PostgreSQL to facilitate finding the required header files and libraries.
To use pg_config, supply one or more of the following options:
--bindir Print the location of user executables. Use this, for example, to find
the psql program. This is normally also the location
where the pg_config program resides.
--docdir Print the location of documentation files. (This will be an empty
string if --without-docdir was specified when
PostgreSQL was built.)
--includedirPrint the location of C header files of the client interfaces.
--pkgincludedirPrint the location of other C header files.
--includedir-serverPrint the location of C header files for server programming.
--libdirPrint the location of object code libraries.
--pkglibdirPrint the location of dynamically loadable modules, or where the server would search for them. (Other architecture-dependent data files may also be installed in this directory.)
--localedirPrint the location of locale support files. (This will be an empty string if locale support was not configured when PostgreSQL was built.)
--mandirPrint the location of manual pages.
--sharedirPrint the location of architecture-independent support files.
--sysconfdirPrint the location of system-wide configuration files.
--pgxsPrint the location of extension makefiles.
--configure Print the options that were given to the configure
script when PostgreSQL was configured for building.
This can be used to reproduce the identical configuration, or
to find out with what options a binary package was built. (Note
however that binary packages often contain vendor-specific custom
patches.) See also the examples below.
--ccPrint the value of the CC macro that was used for building PostgreSQL. This shows the C compiler used.
--cppflags Print the value of the CPPFLAGS macro that was used for building
PostgreSQL. This shows C compiler switches needed
at preprocessing time (typically, -I switches).
--cflagsPrint the value of the CFLAGS macro that was used for building PostgreSQL. This shows C compiler switches.
--cflags_slPrint the value of the CFLAGS_SL macro that was used for building PostgreSQL. This shows extra C compiler switches used for building shared libraries.
--ldflagsPrint the value of the LDFLAGS macro that was used for building PostgreSQL. This shows linker switches.
--ldflags_slPrint the value of the LDFLAGS_SL macro that was used for building PostgreSQL. This shows linker switches used for building shared libraries.
--libs Print the value of the LIBS macro that was used for building
PostgreSQL. This normally contains -l
switches for external libraries linked into PostgreSQL.
--versionPrint the version of PostgreSQL.
If more than one option is given, the information is printed in that order, one item per line. If no options are given, all available information is printed, with labels.
The option --includedir-server was new in
PostgreSQL 7.2. In prior releases, the server include files were
installed in the same location as the client headers, which could
be queried with the option --includedir. To make your
package handle both cases, try the newer option first and test the
exit status to see whether it succeeded.
The options --docdir, --pkgincludedir,
--localedir, --mandir,
--sharedir, --sysconfdir,
--cc, --cppflags,
--cflags, --cflags_sl,
--ldflags, --ldflags_sl,
and --libs are new in PostgreSQL 8.1.
In releases prior to PostgreSQL 7.1, before
pg_config came to be, a method for finding the
equivalent configuration information did not exist.
To reproduce the build configuration of the current PostgreSQL installation, run the following command:
eval ./configure `pg_config --configure`
The output of pg_config --configure contains
shell quotation marks so arguments with spaces are represented
correctly. Therefore, using eval is required
for proper results.