Пример #1
0
static void
show_includedir(bool all)
{
	char		path[MAXPGPATH];

	if (all)
		printf("INCLUDEDIR = ");
	get_include_path(mypath, path);
	cleanup_path(path);
	printf("%s\n", path);
}
Пример #2
0
/*
 * 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 = (ConfigData *) palloc(*configdata_len * sizeof(ConfigData));

	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");
#ifdef VAL_CONFIGURE
	configdata[i].setting = pstrdup(VAL_CONFIGURE);
#else
	configdata[i].setting = pstrdup(_("not recorded"));
#endif
	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;
}
Пример #3
0
int
main(int argc, char **argv)
{
	int			i;
	int			ret;
	char		mypath[MAXPGPATH];
	char		otherpath[MAXPGPATH];

	set_pglocale_pgservice(argv[0], "pg_config");

	progname = get_progname(argv[0]);

	if (argc < 2)
	{
		fprintf(stderr, _("%s: argument required\n"), progname);
		advice();
		exit(1);
	}

	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--bindir") == 0 ||
			strcmp(argv[i], "--includedir") == 0 ||
			strcmp(argv[i], "--includedir-server") == 0 ||
			strcmp(argv[i], "--libdir") == 0 ||
			strcmp(argv[i], "--pkglibdir") == 0 ||
			strcmp(argv[i], "--pgxs") == 0 ||
			strcmp(argv[i], "--configure") == 0)
		{
			/* come back to these later */
			continue;
		}

		if (strcmp(argv[i], "--version") == 0)
		{
			printf("PostgreSQL " PG_VERSION "\n");
			exit(0);
		}
		if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") == 0)
		{
			help();
			exit(0);
		}
		fprintf(stderr, _("%s: invalid argument: %s\n"), progname, argv[i]);
		advice();
		exit(1);
	}

	ret = find_my_exec(argv[0], mypath);

	if (ret)
	{
		fprintf(stderr, _("%s: could not find own executable\n"), progname);
		exit(1);
	}

	for (i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--configure") == 0)
		{
			/* the VAL_CONFIGURE macro must be defined by the Makefile */
			printf("%s\n", VAL_CONFIGURE);
			continue;
		}

		if (strcmp(argv[i], "--bindir") == 0)
		{
			/* assume we are located in the bindir */
			char	   *lastsep;

			strcpy(otherpath, mypath);
			lastsep = strrchr(otherpath, '/');
			if (lastsep)
				*lastsep = '\0';
		}
		else if (strcmp(argv[i], "--includedir") == 0)
			get_include_path(mypath, otherpath);
		else if (strcmp(argv[i], "--includedir-server") == 0)
			get_includeserver_path(mypath, otherpath);
		else if (strcmp(argv[i], "--libdir") == 0)
			get_lib_path(mypath, otherpath);
		else if (strcmp(argv[i], "--pkglibdir") == 0)
			get_pkglib_path(mypath, otherpath);
		else if (strcmp(argv[i], "--pgxs") == 0)
		{
			get_pkglib_path(mypath, otherpath);
			strncat(otherpath, "/pgxs/src/makefiles/pgxs.mk", MAXPGPATH - 1);
		}

		printf("%s\n", otherpath);
	}

	return 0;
}