-# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.7 2004/07/30 12:26:40 petere Exp $
+# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.8 2004/08/01 06:56:38 momjian Exp $
 
 subdir = src/bin/pg_config
 top_builddir = ../../..
 include $(top_builddir)/src/Makefile.global
 
-all: pg_config
+OBJS=   pg_config.o exec.o
 
-pg_config: pg_config.sh $(top_builddir)/src/Makefile.global Makefile
-       sed -e 's,@bindir@,$(bindir),g' \
-           -e 's,@includedir@,$(includedir),g' \
-           -e 's,@includedir_server@,$(includedir_server),g' \
-           -e 's,@libdir@,$(libdir),g' \
-           -e 's,@pkglibdir@,$(pkglibdir),g' \
-           -e 's,@pgxsdir@,$(pgxsdir),g' \
-           -e "s|@configure@|$(configure_args)|g" \
-           -e 's,@version@,$(VERSION),g' \
-         $< >$@
-       chmod a+x $@
+override CPPFLAGS :=  -DFRONTEND -I$(libpq_srcdir) -DVAL_CONFIGURE="\"$(configure_args)\"" $(CPPFLAGS)
 
-install: all installdirs
-       $(INSTALL_SCRIPT) pg_config $(DESTDIR)$(bindir)/pg_config
+all: submake-libpgport pg_config
+
+exec.c: % : $(top_srcdir)/src/port/%
+       rm -f $@ && $(LN_S) $< .
 
+pg_config: $(OBJS)
+       $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
+
+install: all installdirs
+       $(INSTALL_SCRIPT) pg_config$(X) $(DESTDIR)$(bindir)/pg_config$(X)
+  
 installdirs:
        $(mkinstalldirs) $(DESTDIR)$(bindir)
 
        rm -f $(DESTDIR)$(bindir)/pg_config
 
 clean distclean maintainer-clean:
-       rm -f pg_config
+       rm -f pg_config$(X) $(OBJS) exec.c
 
+++ /dev/null
-#! /bin/sh
-
-# This shell script saves various pieces of information about the
-# installed version of PostgreSQL.  Packages that interface to
-# PostgreSQL can use it to configure their build.
-#
-# Author:  Peter Eisentraut <peter_e@gmx.net> 
-# Public domain
-
-# $PostgreSQL: pgsql/src/bin/pg_config/pg_config.sh,v 1.10 2004/07/30 12:26:40 petere Exp $
-
-me=`basename $0`
-
-# stored configuration values
-val_bindir='@bindir@'
-val_includedir='@includedir@'
-val_includedir_server='@includedir_server@'
-val_libdir='@libdir@'
-val_pkglibdir='@pkglibdir@'
-val_pgxsdir='@pgxsdir@'
-val_configure="@configure@"
-val_version='@version@'
-
-help="\
-$me provides information about the installed version of PostgreSQL.
-
-Usage:
-  $me OPTION...
-
-Options:
-  --bindir              show location of user executables
-  --includedir          show location of C header files of the client
-                        interfaces
-  --includedir-server   show location of C header files for the server
-  --libdir              show location of object code libraries
-  --pkglibdir           show location of dynamically loadable modules
-  --pgxs                show location of extension makefile
-  --configure           show options given to 'configure' script when
-                        PostgreSQL was built
-  --version             show the PostgreSQL version, then exit
-  --help                show this help, then exit
-
-Report bugs to <pgsql-bugs@postgresql.org>."
-
-advice="\
-Try \"$me --help\" for more information."
-
-if test "$#" -eq 0 ; then
-    echo "$me: argument required" 1>&2
-    echo "$advice" 1>&2
-    exit 1
-fi
-
-show=
-
-for opt
-do
-    case "$opt" in
-        --bindir)       show="$show \$val_bindir";;
-        --includedir)   show="$show \$val_includedir";;
-        --includedir-server)
-                        show="$show \$val_includedir_server";;
-        --libdir)       show="$show \$val_libdir";;
-        --pkglibdir)    show="$show \$val_pkglibdir";;
-        --pgxs)         show="$show \$val_pgxsdir/src/makefiles/pgxs.mk";;
-        --configure)    show="$show \$val_configure";;
-
-        --version)      echo "PostgreSQL $val_version"
-                        exit 0;;
-        --help|-\?)     echo "$help"
-                        exit 0;;
-        *)              echo "$me: invalid argument: $opt" 1>&2
-                        echo "$advice" 1>&2
-                        exit 1;;
-    esac
-done
-
-for thing in $show
-do
-    eval "echo $thing"
-done
-
-# end of pg_config
 
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/port.h,v 1.46 2004/08/01 06:19:24 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/port.h,v 1.47 2004/08/01 06:56:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 extern void get_etc_path(const char *my_exec_path, char *ret_path);
 extern void get_include_path(const char *my_exec_path, char *ret_path);
 extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
+extern void get_includeserver_path(const char *my_exec_path, char *ret_path);
+extern void get_lib_path(const char *my_exec_path, char *ret_path);
 extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
 extern void get_locale_path(const char *my_exec_path, char *ret_path);
 extern void set_pglocale_pgservice(const char *argv0, const char *app);
 
 # with broken/missing library files.
 
 # IDENTIFICATION
-#    $PostgreSQL: pgsql/src/port/Makefile,v 1.15 2004/05/30 14:07:47 momjian Exp $
+#    $PostgreSQL: pgsql/src/port/Makefile,v 1.16 2004/08/01 06:56:39 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
        echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
        echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
        echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
+       echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
+       echo "#define LIBDIR \"$(libdir)\"" >>$@
        echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
        echo "#define LOCALEDIR \"$(localedir)\"" >>$@
 
 
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/path.c,v 1.25 2004/07/12 19:27:31 momjian Exp $
+ *       $PostgreSQL: pgsql/src/port/path.c,v 1.26 2004/08/01 06:56:39 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 
 
+/*
+ *     get_includeserver_path
+ */
+void
+get_includeserver_path(const char *my_exec_path, char *ret_path)
+{
+       const char *p;
+       
+       if ((p = relative_path(PGBINDIR, INCLUDEDIRSERVER)))
+               make_relative(my_exec_path, p, ret_path);
+       else
+               StrNCpy(ret_path, INCLUDEDIRSERVER, MAXPGPATH);
+       canonicalize_path(ret_path);
+}
+
+
+
+/*
+ *     get_lib_path
+ */
+void
+get_lib_path(const char *my_exec_path, char *ret_path)
+{
+       const char *p;
+       
+       if ((p = relative_path(PGBINDIR, LIBDIR)))
+               make_relative(my_exec_path, p, ret_path);
+       else
+               StrNCpy(ret_path, LIBDIR, MAXPGPATH);
+       canonicalize_path(ret_path);
+}
+
+
+
 /*
  *     get_pkglib_path
- *
- *     Return library path, either relative to /bin or hardcoded
  */
 void
 get_pkglib_path(const char *my_exec_path, char *ret_path)