Skip to content

Commit cbd015d

Browse files
committed
Extend pg_config to be able to report the build-time values of CC,
CPPFLAGS, CFLAGS, CFLAGS_SL, LDFLAGS, LDFLAGS_SL, and LIBS. Change it so that invoking pg_config with no arguments reports all available information, rather than just giving an error message. Per discussion.
1 parent c7bba5e commit cbd015d

File tree

4 files changed

+372
-81
lines changed

4 files changed

+372
-81
lines changed

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

Lines changed: 89 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.20 2005/06/09 18:15:05 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_config-ref.sgml,v 1.21 2005/08/09 22:47:03 tgl Exp $ -->
22

33
<refentry id="app-pgconfig">
44
<refmeta>
@@ -19,16 +19,7 @@
1919
<refsynopsisdiv>
2020
<cmdsynopsis>
2121
<command>pg_config</command>
22-
<group choice="req" rep="repeat">
23-
<arg>--bindir</arg>
24-
<arg>--includedir</arg>
25-
<arg>--includedir-server</arg>
26-
<arg>--libdir</arg>
27-
<arg>--pkglibdir</arg>
28-
<arg>--pgxs</arg>
29-
<arg>--configure</arg>
30-
<arg>--version</arg>
31-
</group>
22+
<arg rep="repeat"><replaceable>option</replaceable></arg>
3223
</cmdsynopsis>
3324
</refsynopsisdiv>
3425

@@ -48,7 +39,8 @@
4839
<title>Options</title>
4940

5041
<para>
51-
To use <application>pg_config</>, supply one or more of the following options:
42+
To use <application>pg_config</>, supply one or more of the following
43+
options:
5244
<variablelist>
5345
<varlistentry>
5446
<term><option>--bindir</option></>
@@ -124,18 +116,93 @@
124116
</listitem>
125117
</varlistentry>
126118

119+
<varlistentry>
120+
<term><option>--cc</option></>
121+
<listitem>
122+
<para>
123+
Print the value of the CC macro that was used for building
124+
<productname>PostgreSQL</>. This shows the C compiler used.
125+
</para>
126+
</listitem>
127+
</varlistentry>
128+
129+
<varlistentry>
130+
<term><option>--cppflags</option></>
131+
<listitem>
132+
<para>
133+
Print the value of the CPPFLAGS macro that was used for building
134+
<productname>PostgreSQL</>. This shows C compiler switches needed
135+
at preprocessing time (typically, <literal>-I</> switches).
136+
</para>
137+
</listitem>
138+
</varlistentry>
139+
140+
<varlistentry>
141+
<term><option>--cflags</option></>
142+
<listitem>
143+
<para>
144+
Print the value of the CFLAGS macro that was used for building
145+
<productname>PostgreSQL</>. This shows C compiler switches.
146+
</para>
147+
</listitem>
148+
</varlistentry>
149+
150+
<varlistentry>
151+
<term><option>--cflags_sl</option></>
152+
<listitem>
153+
<para>
154+
Print the value of the CFLAGS_SL macro that was used for building
155+
<productname>PostgreSQL</>. This shows extra C compiler switches
156+
used for building shared libraries.
157+
</para>
158+
</listitem>
159+
</varlistentry>
160+
161+
<varlistentry>
162+
<term><option>--ldflags</option></>
163+
<listitem>
164+
<para>
165+
Print the value of the LDFLAGS macro that was used for building
166+
<productname>PostgreSQL</>. This shows linker switches.
167+
</para>
168+
</listitem>
169+
</varlistentry>
170+
171+
<varlistentry>
172+
<term><option>--ldflags_sl</option></>
173+
<listitem>
174+
<para>
175+
Print the value of the LDFLAGS_SL macro that was used for building
176+
<productname>PostgreSQL</>. This shows linker switches
177+
used for building shared libraries.
178+
</para>
179+
</listitem>
180+
</varlistentry>
181+
182+
<varlistentry>
183+
<term><option>--libs</option></>
184+
<listitem>
185+
<para>
186+
Print the value of the LIBS macro that was used for building
187+
<productname>PostgreSQL</>. This normally contains <literal>-l</>
188+
switches for external libraries linked into <productname>PostgreSQL</>.
189+
</para>
190+
</listitem>
191+
</varlistentry>
192+
127193
<varlistentry>
128194
<term><option>--version</option></>
129195
<listitem>
130196
<para>
131-
Print the version of <productname>PostgreSQL</> and exit.
197+
Print the version of <productname>PostgreSQL</>.
132198
</para>
133199
</listitem>
134200
</varlistentry>
135201
</variablelist>
136202

137-
If more than one option (except for <option>--version</>) is given, the
138-
information is printed in that order, one item per line.
203+
If more than one option is given, the information is printed in that order,
204+
one item per line. If no options are given, all available information
205+
is printed, with labels.
139206
</para>
140207
</refsect1>
141208

@@ -152,6 +219,13 @@
152219
exit status to see whether it succeeded.
153220
</para>
154221

222+
<para>
223+
The options <option>--cc</option>, <option>--cppflags</option>,
224+
<option>--cflags</option>, <option>--cflags_sl</option>,
225+
<option>--ldflags</option>, <option>--ldflags_sl</option>,
226+
and <option>--libs</option> are new in <productname>PostgreSQL</> 8.1.
227+
</para>
228+
155229
<para>
156230
In releases prior to <productname>PostgreSQL</> 7.1, before
157231
<command>pg_config</command> came to be, a method for finding the

src/bin/pg_config/Makefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2005, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.14 2005/01/20 22:54:57 neilc Exp $
7+
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.15 2005/08/09 22:47:03 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -15,7 +15,19 @@ include $(top_builddir)/src/Makefile.global
1515

1616
OBJS= pg_config.o $(WIN32RES)
1717

18-
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -DVAL_CONFIGURE="\"$(configure_args)\"" $(CPPFLAGS)
18+
# don't include subdirectory-path-dependent -I and -L switches
19+
STD_CPPFLAGS := $(filter-out -I$(top_srcdir)/src/include -I$(top_builddir)/src/include,$(CPPFLAGS))
20+
STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/port,$(LDFLAGS))
21+
22+
override CPPFLAGS += -DFRONTEND
23+
override CPPFLAGS += -DVAL_CONFIGURE="\"$(configure_args)\""
24+
override CPPFLAGS += -DVAL_CC="\"$(CC)\""
25+
override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
26+
override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
27+
override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
28+
override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
29+
override CPPFLAGS += -DVAL_LDFLAGS_SL="\"$(LDFLAGS_SL)\""
30+
override CPPFLAGS += -DVAL_LIBS="\"$(LIBS)\""
1931

2032
all: submake-libpgport pg_config
2133

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy