1
/*-------------------------------------------------------------------------
5
* This program reports various pieces of information about the
6
* installed version of PostgreSQL. Packages that interface to
7
* PostgreSQL can use it to configure their build.
9
* This is a C implementation of the previous shell script written by
10
* Peter Eisentraut <peter_e@gmx.net>, with adjustments made to
11
* accomodate the possibility that the installation has been relocated from
12
* the place originally configured.
14
* author of C translation: Andrew Dunstan mailto:andrew@dunslane.net
16
* This code is released under the terms of the PostgreSQL License.
18
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
20
* $PostgreSQL: pgsql/src/bin/pg_config/pg_config.c,v 1.10 2004-12-31 22:03:03 pgsql Exp $
22
*-------------------------------------------------------------------------
29
#define _(x) gettext((x))
31
static const char *progname;
36
printf(_("\n%s provides information about the installed version of PostgreSQL.\n\n"), progname);
37
printf(_("Usage:\n"));
38
printf(_(" %s OPTION...\n\n"), progname);
39
printf(_("Options:\n"));
40
printf(_(" --bindir show location of user executables\n"));
41
printf(_(" --includedir show location of C header files of the client\n"
43
printf(_(" --includedir-server show location of C header files for the server\n"));
44
printf(_(" --libdir show location of object code libraries\n"));
45
printf(_(" --pkglibdir show location of dynamically loadable modules\n"));
46
printf(_(" --pgxs show location of extension makefile\n"));
47
printf(_(" --configure show options given to \"configure\" script when\n"
48
" PostgreSQL was built\n"));
49
printf(_(" --version show the PostgreSQL version, then exit\n"));
50
printf(_(" --help show this help, then exit\n\n"));
51
printf(_("Report bugs to <pgsql-bugs@postgresql.org>.\n"));
57
fprintf(stderr, _("\nTry \"%s --help\" for more information\n"), progname);
62
main(int argc, char **argv)
66
char mypath[MAXPGPATH];
67
char otherpath[MAXPGPATH];
69
set_pglocale_pgservice(argv[0], "pg_config");
71
progname = get_progname(argv[0]);
75
fprintf(stderr, _("%s: argument required\n"), progname);
80
for (i = 1; i < argc; i++)
82
if (strcmp(argv[i], "--bindir") == 0 ||
83
strcmp(argv[i], "--includedir") == 0 ||
84
strcmp(argv[i], "--includedir-server") == 0 ||
85
strcmp(argv[i], "--libdir") == 0 ||
86
strcmp(argv[i], "--pkglibdir") == 0 ||
87
strcmp(argv[i], "--pgxs") == 0 ||
88
strcmp(argv[i], "--configure") == 0)
90
/* come back to these later */
94
if (strcmp(argv[i], "--version") == 0)
96
printf("PostgreSQL " PG_VERSION "\n");
99
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
104
fprintf(stderr, _("%s: invalid argument: %s\n"), progname, argv[i]);
109
ret = find_my_exec(argv[0], mypath);
113
fprintf(stderr, _("%s: could not find own executable\n"), progname);
117
for (i = 1; i < argc; i++)
119
if (strcmp(argv[i], "--configure") == 0)
121
/* the VAL_CONFIGURE macro must be defined by the Makefile */
122
printf("%s\n", VAL_CONFIGURE);
126
if (strcmp(argv[i], "--bindir") == 0)
128
/* assume we are located in the bindir */
131
strcpy(otherpath, mypath);
132
lastsep = strrchr(otherpath, '/');
136
else if (strcmp(argv[i], "--includedir") == 0)
137
get_include_path(mypath, otherpath);
138
else if (strcmp(argv[i], "--includedir-server") == 0)
139
get_includeserver_path(mypath, otherpath);
140
else if (strcmp(argv[i], "--libdir") == 0)
141
get_lib_path(mypath, otherpath);
142
else if (strcmp(argv[i], "--pkglibdir") == 0)
143
get_pkglib_path(mypath, otherpath);
144
else if (strcmp(argv[i], "--pgxs") == 0)
146
get_pkglib_path(mypath, otherpath);
147
strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1);
150
printf("%s\n", otherpath);