Skip to content

Commit f5944af

Browse files
committed
Include directory rearrangement
Client headers are no longer in a subdirectory, since they have been made namespace-clean. Internal libpq headers are in a private subdirectory. Server headers are in a private subdirectory. pg_config has a new option to point there.
1 parent 3fcea50 commit f5944af

File tree

9 files changed

+270
-90
lines changed

9 files changed

+270
-90
lines changed

doc/src/sgml/installation.sgml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.50 2001/06/02 18:25:16 petere Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.51 2001/08/28 14:20:24 petere Exp $ -->
22

33
<chapter id="installation">
44
<title><![%flattext-install-include[<productname>PostgreSQL</>]]>
@@ -448,19 +448,29 @@ su - postgres
448448

449449
<note>
450450
<para>
451-
To reduce the pollution of shared installation locations (such
452-
as <filename>/usr/local/include</filename>), the string
453-
<quote><literal>/postgresql</literal></quote> is automatically
454-
appended to <varname>datadir</varname>,
455-
<varname>sysconfdir</varname>, <varname>includedir</varname>,
456-
and <varname>docdir</varname>, unless the fully expanded
457-
directory name already contains the string
458-
<quote>postgres</quote> or <quote>pgsql</quote>. For example,
459-
if you choose <filename>/usr/local</filename> as prefix, the C
460-
header files will be installed in
461-
<filename>/usr/local/include/postgresql</filename>, but if the
462-
prefix is <filename>/opt/postgres</filename>, then they will be
463-
in <filename>/opt/postgres/include</filename>.
451+
Care has been taken to make it possible to install PostgreSQL
452+
into shared installation locations (such as
453+
<filename>/usr/local/include</filename>) without interfering
454+
with the namespace of the rest of the system. First, the
455+
string <quote><literal>/postgresql</literal></quote> is
456+
automatically appended to <varname>datadir</varname>,
457+
<varname>sysconfdir</varname>, and <varname>docdir</varname>,
458+
unless the fully expanded directory name already contains the
459+
string <quote>postgres</quote> or <quote>pgsql</quote>. For
460+
example, if you choose <filename>/usr/local</filename> as
461+
prefix, the documentation will be installed in
462+
<filename>/usr/local/doc/postgresql</filename>, but if the
463+
prefix is <filename>/opt/postgres</filename>, then it will be
464+
in <filename>/opt/postgres/doc</filename>. Second, the
465+
installation layout of the C and C++ header files has been
466+
reorganized in the 7.2 release. The public header files of the
467+
client interfaces are installed into
468+
<varname>includedir</varname> and are namespace-clean. The
469+
internal header files and the server header files are installed
470+
into private directories under
471+
<filename><replaceable>includedir</replaceable>/postgresql</filename>.
472+
See the <citetitle>Programmer's Guide</citetitle> for
473+
information how to get at the header files for each interface.
464474
</para>
465475
</note>
466476
</para>

doc/src/sgml/libpq.sgml

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.66 2001/08/10 22:50:09 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.67 2001/08/28 14:20:25 petere Exp $
33
-->
44

55
<chapter id="libpq">
@@ -1994,6 +1994,129 @@ call <function>fe_setauthsvc</function> at all.
19941994
</sect1>
19951995

19961996

1997+
<sect1 id="libpq-build">
1998+
<title>Building Libpq Programs</title>
1999+
2000+
<para>
2001+
To build (i.e., compile and link) your libpq programs you need to
2002+
do the following things:
2003+
2004+
<itemizedlist>
2005+
<listitem>
2006+
<para>
2007+
Include the <filename>libpq-fe.h</filename> header file:
2008+
<programlisting>
2009+
#include &lt;libpq-fe&gt;
2010+
</programlisting>
2011+
If you failed to do that then you will normally get error
2012+
messages from your compiler, such as
2013+
<screen>
2014+
foo.c: In function `main':
2015+
foo.c:34: `PGconn' undeclared (first use in this function)
2016+
foo.c:35: `PGresult' undeclared (first use in this function)
2017+
foo.c:54: `CONNECTION_BAD' undeclared (first use in this function)
2018+
foo.c:68: `PGRES_COMMAND_OK' undeclared (first use in this function)
2019+
foo.c:95: `PGRES_TUPLES_OK' undeclared (first use in this function)
2020+
</screen>
2021+
</para>
2022+
</listitem>
2023+
2024+
<listitem>
2025+
<para>
2026+
Point your compiler to the directory where the PostgreSQL header
2027+
files were installed, by supplying the
2028+
<literal>-I<replaceable>directory</replaceable></literal> option
2029+
to your compiler. (In some cases the compiler will look into
2030+
the directory in question by default, so you can omit this
2031+
option.) For instance, your compile command line could look
2032+
like:
2033+
<programlisting>
2034+
cc -c -I/usr/local/pgsql/include testprog.c
2035+
</programlisting>
2036+
If you are using makefiles then add the option to the
2037+
<varname>CPPFLAGS</varname> variable:
2038+
<programlisting>
2039+
CPPFLAGS += -I/usr/local/pgsql/include
2040+
</programlisting>
2041+
</para>
2042+
2043+
<para>
2044+
If there is any chance that your program might be compiled by
2045+
other users then you should not hardcode the directory location
2046+
like that. Instead, you can run the utility
2047+
<command>pg_config</command> to find out where the header files
2048+
are on the local system:
2049+
<screen>
2050+
<prompt>$</prompt> pg_config --includedir
2051+
<computeroutput>/usr/local/include</computeroutput>
2052+
</screen>
2053+
</para>
2054+
2055+
<para>
2056+
Failure to specify the correct option to the compiler will
2057+
result in an error message such as
2058+
<screen>
2059+
testlibpq.c:8:22: libpq-fe.h: No such file or directory
2060+
</screen>
2061+
</para>
2062+
</listitem>
2063+
2064+
<listitem>
2065+
<para>
2066+
When linking the final program, specify the option
2067+
<literal>-lpq</literal> so that the libpq library gets pulled
2068+
in, as well as the option
2069+
<literal>-L<replaceable>directory</replaceable></literal> to
2070+
point it to the directory where libpq resides. (Again, the
2071+
compiler will search some directories by default.) For maximum
2072+
portability, put the <option>-L</option> option before the
2073+
<option>-lpq</option> option. For example:
2074+
<programlisting>
2075+
cc -o testprog testprog1.o testprog2.o -L/usr/local/pgsql/lib -lpq
2076+
</programlisting>
2077+
</para>
2078+
2079+
<para>
2080+
You can find out the library directory using
2081+
<command>pg_config</command> as well:
2082+
<screen>
2083+
<prompt>$</prompt> pg_config --libdir
2084+
<computeroutput>/usr/local/pgsql/lib</computeroutput>
2085+
</screen>
2086+
</para>
2087+
2088+
<para>
2089+
Error messages that point to problems in this area could look
2090+
like the following.
2091+
<screen>
2092+
testlibpq.o: In function `main':
2093+
testlibpq.o(.text+0x60): undefined reference to `PQsetdbLogin'
2094+
testlibpq.o(.text+0x71): undefined reference to `PQstatus'
2095+
testlibpq.o(.text+0xa4): undefined reference to `PQerrorMessage'
2096+
</screen>
2097+
This means you forgot <option>-lpq</option>.
2098+
<screen>
2099+
/usr/bin/ld: cannot find -lpq
2100+
</screen>
2101+
This means you forgot the <option>-L</option> or did not specify
2102+
the right path.
2103+
</para>
2104+
</listitem>
2105+
</itemizedlist>
2106+
</para>
2107+
2108+
<para>
2109+
If your codes references the header file
2110+
<filename>libpq-int.h</filename> and you refuse to fix your code to
2111+
not use it, starting in PostgreSQL 7.2, this file will be found in
2112+
<filename><replaceable>includedir</replaceable>/postgresql/internal/libpq-int.h</filename>,
2113+
so you need to add the appropriate <option>-I</option> option to
2114+
your compiler command line.
2115+
</para>
2116+
2117+
</sect1>
2118+
2119+
19972120
<sect1 id="libpq-example">
19982121
<title>Example Programs</title>
19992122

doc/src/sgml/ref/pg_config-ref.sgml

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.5 2001/03/05 18:42:56 momjian Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.6 2001/08/28 14:20:26 petere Exp $ -->
22

33
<refentry id="app-pgconfig">
44
<docinfo>
@@ -22,6 +22,7 @@
2222
<group choice="req" rep="repeat">
2323
<arg>--bindir</arg>
2424
<arg>--includedir</arg>
25+
<arg>--includedir-server</arg>
2526
<arg>--libdir</arg>
2627
<arg>--configure</arg>
2728
<arg>--version</arg>
@@ -32,12 +33,17 @@
3233
<refsect1>
3334
<title>Description</>
3435
<para>
35-
The <application>pg_config</> utility provides configuration parameters
36+
The <application>pg_config</> utility prints configuration parameters
3637
of the currently installed version of <productname>PostgreSQL</>. It is
3738
intended, for example, to be used by software packages that want to interface
38-
to <productname>PostgreSQL</> in order to find the respective header files
39+
to <productname>PostgreSQL</> to facilitate finding the required header files
3940
and libraries.
4041
</para>
42+
</refsect1>
43+
44+
45+
<refsect1>
46+
<title>Options</title>
4147

4248
<para>
4349
To use <application>pg_config</>, supply one or more of the following options:
@@ -57,7 +63,17 @@
5763
<term>--includedir</>
5864
<listitem>
5965
<para>
60-
Print the location of C and C++ header files.
66+
Print the location of C and C++ header files of the client interfaces.
67+
</para>
68+
</listitem>
69+
</varlistentry>
70+
71+
<varlistentry>
72+
<term>--includedir-server</>
73+
<listitem>
74+
<para>
75+
Print the location of C and C++ header files for server
76+
programming.
6177
</para>
6278
</listitem>
6379
</varlistentry>
@@ -99,4 +115,42 @@
99115
information is printed in that order, one item per line.
100116
</para>
101117
</refsect1>
118+
119+
120+
<refsect1>
121+
<title>Notes</title>
122+
123+
<para>
124+
The option <option>--includedir-server</option> is new in
125+
PostgreSQL 7.2. In prior releases, the server include files were
126+
installed in the same location as the client headers, which could
127+
be queried with the <option>--includedir</option>. To make your
128+
package handle both cases, try the newer option first and test the
129+
exit status to see whether it succeeded.
130+
</para>
131+
132+
<para>
133+
In releases prior to PostgreSQL 7.1, before the
134+
<command>pg_config</command> came to be, a method for finding the
135+
equivalent configuration information did not exist.
136+
</para>
137+
</refsect1>
138+
139+
140+
<refsect1>
141+
<title>History</title>
142+
143+
<para>
144+
The <command>pg_config</command> utility first appeared in PostgreSQL 7.1.
145+
</para>
146+
</refsect1>
147+
148+
149+
<refsect1>
150+
<title>See Also</title>
151+
152+
<para>
153+
<citetitle>PostgreSQL Programmer's Guide</citetitle>
154+
</para>
155+
</refsect1>
102156
</refentry>

doc/src/sgml/xfunc.sgml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.32 2001/05/19 09:01:10 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.33 2001/08/28 14:20:26 petere Exp $
33
-->
44

55
<chapter id="xfunc">
@@ -1203,13 +1203,16 @@ LANGUAGE 'c';
12031203
<itemizedlist>
12041204
<listitem>
12051205
<para>
1206-
The relevant header (include) files are installed under
1207-
<filename>/usr/local/pgsql/include</filename> or equivalent.
1208-
You can use <literal>pg_config --includedir</literal> to find
1209-
out where it is on your system (or the system that your
1210-
users will be running on). For very low-level work you might
1211-
need to have a complete <productname>PostgreSQL</productname>
1212-
source tree available.
1206+
Use <literal>pg_config --includedir-server</literal> to find
1207+
out where the PostgreSQL server header files are installed on
1208+
your system (or the system that your users will be running
1209+
on). This option is new with PostgreSQL 7.2. For PostgreSQL
1210+
7.1 you should use the option <option>--includedir</option>.
1211+
(<command>pg_config</command> will exit with a non-zero status
1212+
if it encounters an unknown option.) For releases prior to
1213+
7.1 you will have to guess, but since that was before the
1214+
current calling conventions were introduced, it is unlikely
1215+
that you want to support those releases.
12131216
</para>
12141217
</listitem>
12151218

src/Makefile.global.in

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.134 2001/08/27 00:29:49 petere Exp $
2+
# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.135 2001/08/28 14:20:26 petere Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -83,11 +83,9 @@ libdir := @libdir@
8383
pkglibdir = $(libdir)/postgresql
8484

8585
includedir := @includedir@
86-
ifeq "$(findstring pgsql, $(includedir))" ""
87-
ifeq "$(findstring postgres, $(includedir))" ""
88-
override includedir := $(includedir)/postgresql
89-
endif
90-
endif
86+
pkgincludedir = $(includedir)/postgresql
87+
includedir_server = $(pkgincludedir)/server
88+
includedir_internal = $(pkgincludedir)/internal
9189

9290
mandir := @mandir@
9391

src/bin/pg_config/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/src/bin/pg_config/Makefile,v 1.1 2000/10/10 22:01:55 momjian Exp $
1+
# $Header: /cvsroot/pgsql/src/bin/pg_config/Makefile,v 1.2 2001/08/28 14:20:28 petere Exp $
22

33
subdir = src/bin/pg_config
44
top_builddir = ../../..
@@ -10,6 +10,7 @@ pg_config: pg_config.sh $(top_builddir)/config.status $(top_builddir)/src/Makefi
1010
configure=`sed -n '7s,^# [^ ]*configure *,,p' $(top_builddir)/config.status` && \
1111
sed -e 's,@bindir@,$(bindir),g' \
1212
-e 's,@includedir@,$(includedir),g' \
13+
-e 's,@includedir_server@,$(includedir_server),g' \
1314
-e 's,@libdir@,$(libdir),g' \
1415
-e "s,@configure@,$$configure,g" \
1516
-e 's,@version@,$(VERSION),g' \

src/bin/pg_config/pg_config.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@
77
# Author: Peter Eisentraut <peter_e@gmx.net>
88
# Public domain
99

10-
# $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.3 2001/05/13 00:12:05 petere Exp $
10+
# $Header: /cvsroot/pgsql/src/bin/pg_config/Attic/pg_config.sh,v 1.4 2001/08/28 14:20:28 petere Exp $
1111

1212
me=`basename $0`
1313

1414
# stored configuration values
1515
val_bindir='@bindir@'
1616
val_includedir='@includedir@'
17+
val_includedir_server='@includedir_server@'
1718
val_libdir='@libdir@'
1819
val_configure="@configure@"
1920
val_version='@version@'
2021

2122
help="\
2223
$me provides information about the installed version of PostgreSQL.
2324
24-
Usage: $me --bindir | --includedir | --libdir | --configure | --version
25+
Usage: $me --bindir | --includedir | --includedir-server | --libdir | --configure | --version
2526
2627
Operation modes:
27-
--bindir show location of user executables
28-
--includedir show location of C header files
29-
--libdir show location of object code libraries
30-
--configure show options given to 'configure' script when
31-
PostgreSQL was built
32-
--version show PostgreSQL version and exit
28+
--bindir show location of user executables
29+
--includedir show location of C header files of the client
30+
interfaces
31+
--includedir-server show location of C header files for the server
32+
--libdir show location of object code libraries
33+
--configure show options given to 'configure' script when
34+
PostgreSQL was built
35+
--version show the PostgreSQL version and exit
3336
3437
Report bugs to <pgsql-bugs@postgresql.org>."
3538

@@ -49,6 +52,8 @@ do
4952
case $opt in
5053
--bindir) show="$show \$val_bindir";;
5154
--includedir) show="$show \$val_includedir";;
55+
--includedir-server)
56+
show="$show \$val_includedir_server";;
5257
--libdir) show="$show \$val_libdir";;
5358
--configure) show="$show \$val_configure";;
5459

0 commit comments

Comments
 (0)