*** a/src/common/Makefile
--- b/src/common/Makefile
***************
*** 25,31 **** LIBS += $(PTHREAD_LIBS)
  
  OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o wait_error.o
  
! OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o
  
  OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
  
--- 25,31 ----
  
  OBJS_COMMON = exec.o pgfnames.o psprintf.o relpath.o rmtree.o wait_error.o
  
! OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o fe_path.o
  
  OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
  
*** /dev/null
--- b/src/common/fe_path.c
***************
*** 0 ****
--- 1,93 ----
+ /*-------------------------------------------------------------------------
+  *
+  * fe_path.c
+  *	  path functions support for frontend code
+  *
+  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+  * Portions Copyright (c) 1994, Regents of the University of California
+  *
+  *
+  * IDENTIFICATION
+  *	  src/common/fe_path.c
+  *
+  *-------------------------------------------------------------------------
+  */
+ 
+ #ifndef FRONTEND
+ #error "This file is not expected to be compiled for backend code"
+ #endif
+ 
+ #include "postgres_fe.h"
+ #include <unistd.h>
+ 
+ /*
+  * If the given pathname isn't already absolute, make it so, interpreting
+  * it relative to the current working directory.
+  *
+  * Also canonicalizes the path.  The result is always a malloc'd copy.
+  */
+ char *
+ make_absolute_path(const char *path)
+ {
+ 	char	   *result;
+ 
+ 	/* Returning null for null input is convenient for some callers */
+ 	if (path == NULL)
+ 		return NULL;
+ 
+ 	if (!is_absolute_path(path))
+ 	{
+ 		char	   *buf;
+ 		size_t		buflen;
+ 
+ 		buflen = MAXPGPATH;
+ 		for (;;)
+ 		{
+ 			buf = malloc(buflen);
+ 			if (!buf)
+ 			{
+ 				fprintf(stderr, _("out of memory\n"));
+ 				exit(EXIT_FAILURE);
+ 			}
+ 
+ 			if (getcwd(buf, buflen))
+ 				break;
+ 			else if (errno == ERANGE)
+ 			{
+ 				free(buf);
+ 				buflen *= 2;
+ 				continue;
+ 			}
+ 			else
+ 			{
+ 				free(buf);
+ 				fprintf(stderr, _("could not get current working directory :%s \n"), strerror(errno));
+ 				exit(EXIT_FAILURE);
+ 			}
+ 		}
+ 
+ 		result = malloc(strlen(buf) + strlen(path) + 2);
+ 		if (!result)
+ 		{
+ 			fprintf(stderr, _("out of memory\n"));
+ 			exit(EXIT_FAILURE);
+ 		}
+ 
+ 		sprintf(result, "%s/%s", buf, path);
+ 		free(buf);
+ 	}
+ 	else
+ 	{
+ 		result = strdup(path);
+ 		if (!result)
+ 		{
+ 			fprintf(stderr, _("out of memory\n"));
+ 			exit(EXIT_FAILURE);
+ 		}
+ 	}
+ 
+ 	/* Make sure punctuation is canonical, too */
+ 	canonicalize_path(result);
+ 
+ 	return result;
+ }
*** /dev/null
--- b/src/include/common/fe_path.h
***************
*** 0 ****
--- 1,14 ----
+ /*
+  *	fe_path.h
+  *		path functions support for frontend code
+  *
+  *	Copyright (c) 2003-2013, PostgreSQL Global Development Group
+  *
+  *	src/include/common/fe_path.h
+  */
+ #ifndef FE_PATH_H
+ #define FE_PATH_H
+ 
+ extern char *make_absolute_path(const char *path);
+ 
+ #endif   /* FE_PATH_H */
*** a/src/include/postgres_fe.h
--- b/src/include/postgres_fe.h
***************
*** 25,29 ****
--- 25,30 ----
  #include "c.h"
  
  #include "common/fe_memutils.h"
+ #include "common/fe_path.h"
  
  #endif   /* POSTGRES_FE_H */
*** a/src/test/regress/pg_regress.c
--- b/src/test/regress/pg_regress.c
***************
*** 1832,1864 **** create_role(const char *rolename, const _stringlist * granted_dbs)
  	}
  }
  
- static char *
- make_absolute_path(const char *in)
- {
- 	char	   *result;
- 
- 	if (is_absolute_path(in))
- 		result = strdup(in);
- 	else
- 	{
- 		static char cwdbuf[MAXPGPATH];
- 
- 		if (!cwdbuf[0])
- 		{
- 			if (!getcwd(cwdbuf, sizeof(cwdbuf)))
- 			{
- 				fprintf(stderr, _("could not get current working directory: %s\n"), strerror(errno));
- 				exit(2);
- 			}
- 		}
- 
- 		result = psprintf("%s/%s", cwdbuf, in);
- 	}
- 
- 	canonicalize_path(result);
- 	return result;
- }
- 
  static void
  help(void)
  {
--- 1832,1837 ----
