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