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