1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
/*-------------------------------------------------------------------------
*
* config_info.c
* Common code for pg_config output
*
*
* Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* src/common/config_info.c
*
*-------------------------------------------------------------------------
*/
#ifndef FRONTEND
#include "postgres.h"
#else
#include "postgres_fe.h"
#endif
#include "common/config_info.h"
/*
* get_configdata(const char *my_exec_path, size_t *configdata_len)
*
* Get configure-time constants. The caller is responsible
* for pfreeing the result.
*/
ConfigData *
get_configdata(const char *my_exec_path, size_t *configdata_len)
{
ConfigData *configdata;
char path[MAXPGPATH];
char *lastsep;
int i = 0;
/* Adjust this to match the number of items filled below */
*configdata_len = 23;
configdata = palloc_array(ConfigData, *configdata_len);
configdata[i].name = pstrdup("BINDIR");
strlcpy(path, my_exec_path, sizeof(path));
lastsep = strrchr(path, '/');
if (lastsep)
*lastsep = '\0';
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("DOCDIR");
get_doc_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("HTMLDIR");
get_html_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("INCLUDEDIR");
get_include_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("PKGINCLUDEDIR");
get_pkginclude_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("INCLUDEDIR-SERVER");
get_includeserver_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("LIBDIR");
get_lib_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("PKGLIBDIR");
get_pkglib_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("LOCALEDIR");
get_locale_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("MANDIR");
get_man_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("SHAREDIR");
get_share_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("SYSCONFDIR");
get_etc_path(my_exec_path, path);
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("PGXS");
get_pkglib_path(my_exec_path, path);
strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
cleanup_path(path);
configdata[i].setting = pstrdup(path);
i++;
configdata[i].name = pstrdup("CONFIGURE");
configdata[i].setting = pstrdup(CONFIGURE_ARGS);
i++;
configdata[i].name = pstrdup("CC");
#ifdef VAL_CC
configdata[i].setting = pstrdup(VAL_CC);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("CPPFLAGS");
#ifdef VAL_CPPFLAGS
configdata[i].setting = pstrdup(VAL_CPPFLAGS);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("CFLAGS");
#ifdef VAL_CFLAGS
configdata[i].setting = pstrdup(VAL_CFLAGS);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("CFLAGS_SL");
#ifdef VAL_CFLAGS_SL
configdata[i].setting = pstrdup(VAL_CFLAGS_SL);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("LDFLAGS");
#ifdef VAL_LDFLAGS
configdata[i].setting = pstrdup(VAL_LDFLAGS);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("LDFLAGS_EX");
#ifdef VAL_LDFLAGS_EX
configdata[i].setting = pstrdup(VAL_LDFLAGS_EX);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("LDFLAGS_SL");
#ifdef VAL_LDFLAGS_SL
configdata[i].setting = pstrdup(VAL_LDFLAGS_SL);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("LIBS");
#ifdef VAL_LIBS
configdata[i].setting = pstrdup(VAL_LIBS);
#else
configdata[i].setting = pstrdup(_("not recorded"));
#endif
i++;
configdata[i].name = pstrdup("VERSION");
configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION);
i++;
Assert(i == *configdata_len);
return configdata;
}
|