1 /*-------------------------------------------------------------------------
4 * Common code for pg_config output
7 * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
12 * src/common/config_info.c
14 *-------------------------------------------------------------------------
20 #include "postgres_fe.h"
23 #include "common/config_info.h"
24 #include "miscadmin.h"
28 * get_configdata(const char *my_exec_path, size_t *configdata_len)
30 * Get configure-time constants. The caller is responsible
31 * for pfreeing the result.
34 get_configdata(const char *my_exec_path, size_t *configdata_len)
36 ConfigData *configdata;
41 /* Adjust this to match the number of items filled below */
43 configdata = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData));
45 configdata[i].name = pstrdup("BINDIR");
46 strlcpy(path, my_exec_path, sizeof(path));
47 lastsep = strrchr(path, '/');
51 configdata[i].setting = pstrdup(path);
54 configdata[i].name = pstrdup("DOCDIR");
55 get_doc_path(my_exec_path, path);
57 configdata[i].setting = pstrdup(path);
60 configdata[i].name = pstrdup("HTMLDIR");
61 get_html_path(my_exec_path, path);
63 configdata[i].setting = pstrdup(path);
66 configdata[i].name = pstrdup("INCLUDEDIR");
67 get_include_path(my_exec_path, path);
69 configdata[i].setting = pstrdup(path);
72 configdata[i].name = pstrdup("PKGINCLUDEDIR");
73 get_pkginclude_path(my_exec_path, path);
75 configdata[i].setting = pstrdup(path);
78 configdata[i].name = pstrdup("INCLUDEDIR-SERVER");
79 get_includeserver_path(my_exec_path, path);
81 configdata[i].setting = pstrdup(path);
84 configdata[i].name = pstrdup("LIBDIR");
85 get_lib_path(my_exec_path, path);
87 configdata[i].setting = pstrdup(path);
90 configdata[i].name = pstrdup("PKGLIBDIR");
91 get_pkglib_path(my_exec_path, path);
93 configdata[i].setting = pstrdup(path);
96 configdata[i].name = pstrdup("LOCALEDIR");
97 get_locale_path(my_exec_path, path);
99 configdata[i].setting = pstrdup(path);
102 configdata[i].name = pstrdup("MANDIR");
103 get_man_path(my_exec_path, path);
105 configdata[i].setting = pstrdup(path);
108 configdata[i].name = pstrdup("SHAREDIR");
109 get_share_path(my_exec_path, path);
111 configdata[i].setting = pstrdup(path);
114 configdata[i].name = pstrdup("SYSCONFDIR");
115 get_etc_path(my_exec_path, path);
117 configdata[i].setting = pstrdup(path);
120 configdata[i].name = pstrdup("PGXS");
121 get_pkglib_path(my_exec_path, path);
122 strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path));
124 configdata[i].setting = pstrdup(path);
127 configdata[i].name = pstrdup("CONFIGURE");
129 configdata[i].setting = pstrdup(VAL_CONFIGURE);
131 configdata[i].setting = pstrdup(_("not recorded"));
135 configdata[i].name = pstrdup("CC");
137 configdata[i].setting = pstrdup(VAL_CC);
139 configdata[i].setting = pstrdup(_("not recorded"));
143 configdata[i].name = pstrdup("CPPFLAGS");
145 configdata[i].setting = pstrdup(VAL_CPPFLAGS);
147 configdata[i].setting = pstrdup(_("not recorded"));
151 configdata[i].name = pstrdup("CFLAGS");
153 configdata[i].setting = pstrdup(VAL_CFLAGS);
155 configdata[i].setting = pstrdup(_("not recorded"));
159 configdata[i].name = pstrdup("CFLAGS_SL");
161 configdata[i].setting = pstrdup(VAL_CFLAGS_SL);
163 configdata[i].setting = pstrdup(_("not recorded"));
167 configdata[i].name = pstrdup("LDFLAGS");
169 configdata[i].setting = pstrdup(VAL_LDFLAGS);
171 configdata[i].setting = pstrdup(_("not recorded"));
175 configdata[i].name = pstrdup("LDFLAGS_EX");
176 #ifdef VAL_LDFLAGS_EX
177 configdata[i].setting = pstrdup(VAL_LDFLAGS_EX);
179 configdata[i].setting = pstrdup(_("not recorded"));
183 configdata[i].name = pstrdup("LDFLAGS_SL");
184 #ifdef VAL_LDFLAGS_SL
185 configdata[i].setting = pstrdup(VAL_LDFLAGS_SL);
187 configdata[i].setting = pstrdup(_("not recorded"));
191 configdata[i].name = pstrdup("LIBS");
193 configdata[i].setting = pstrdup(VAL_LIBS);
195 configdata[i].setting = pstrdup(_("not recorded"));
199 configdata[i].name = pstrdup("VERSION");
200 configdata[i].setting = pstrdup("PostgreSQL " PG_VERSION);
203 Assert(i == *configdata_len);