Create a C version of pg_config.
authorBruce Momjian <bruce@momjian.us>
Sun, 1 Aug 2004 06:56:39 +0000 (06:56 +0000)
committerBruce Momjian <bruce@momjian.us>
Sun, 1 Aug 2004 06:56:39 +0000 (06:56 +0000)
Andrew Dunstan

src/bin/pg_config/Makefile
src/bin/pg_config/pg_config.sh [deleted file]
src/include/port.h
src/port/Makefile
src/port/path.c

index 8fa0f94a7e905b60afb3b76e980c73ffff443074..472a32d00701fc9cfc88410b1e09e8eca031a9d1 100644 (file)
@@ -1,26 +1,24 @@
-# $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)
 
@@ -28,4 +26,4 @@ uninstall:
        rm -f $(DESTDIR)$(bindir)/pg_config
 
 clean distclean maintainer-clean:
-       rm -f pg_config
+       rm -f pg_config$(X) $(OBJS) exec.c
diff --git a/src/bin/pg_config/pg_config.sh b/src/bin/pg_config/pg_config.sh
deleted file mode 100644 (file)
index 673462d..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#! /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
index ac3634e0eefd1327e42589c1500fb399ff1ef450..731ec4120a41d2191feb5794814b67865086f784 100644 (file)
@@ -6,7 +6,7 @@
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,6 +44,8 @@ extern void get_share_path(const char *my_exec_path, char *ret_path);
 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);
index 4684cb024e49113e7391be861c77181d7cd845d7..dc2ddee3e6a7ca5d375a89346b63ec74c2c08a9b 100644 (file)
@@ -7,7 +7,7 @@
 # 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 $
 #
 #-------------------------------------------------------------------------
 
@@ -35,6 +35,8 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
        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)\"" >>$@
 
index aaecf33f741f7f72b4aac81717fac89705714245..1e45a8f3e2c69c7e37d7ec21fa5871b8852603b2 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -205,10 +205,42 @@ get_pkginclude_path(const char *my_exec_path, char *ret_path)
 
 
 
+/*
+ *     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)