Skip to content

Commit cc07f8c

Browse files
committed
Create a C version of pg_config.
Andrew Dunstan
1 parent 7510ac6 commit cc07f8c

File tree

5 files changed

+55
-104
lines changed

5 files changed

+55
-104
lines changed

src/bin/pg_config/Makefile

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.7 2004/07/30 12:26:40 petere Exp $
1+
# $PostgreSQL: pgsql/src/bin/pg_config/Makefile,v 1.8 2004/08/01 06:56:38 momjian Exp $
22

33
subdir = src/bin/pg_config
44
top_builddir = ../../..
55
include $(top_builddir)/src/Makefile.global
66

7-
all: pg_config
7+
OBJS= pg_config.o exec.o
88

9-
pg_config: pg_config.sh $(top_builddir)/src/Makefile.global Makefile
10-
sed -e 's,@bindir@,$(bindir),g' \
11-
-e 's,@includedir@,$(includedir),g' \
12-
-e 's,@includedir_server@,$(includedir_server),g' \
13-
-e 's,@libdir@,$(libdir),g' \
14-
-e 's,@pkglibdir@,$(pkglibdir),g' \
15-
-e 's,@pgxsdir@,$(pgxsdir),g' \
16-
-e "s|@configure@|$(configure_args)|g" \
17-
-e 's,@version@,$(VERSION),g' \
18-
$< >$@
19-
chmod a+x $@
9+
override CPPFLAGS := -DFRONTEND -I$(libpq_srcdir) -DVAL_CONFIGURE="\"$(configure_args)\"" $(CPPFLAGS)
2010

21-
install: all installdirs
22-
$(INSTALL_SCRIPT) pg_config $(DESTDIR)$(bindir)/pg_config
11+
all: submake-libpgport pg_config
12+
13+
exec.c: % : $(top_srcdir)/src/port/%
14+
rm -f $@ && $(LN_S) $< .
2315

16+
pg_config: $(OBJS)
17+
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) -o $@$(X)
18+
19+
install: all installdirs
20+
$(INSTALL_SCRIPT) pg_config$(X) $(DESTDIR)$(bindir)/pg_config$(X)
21+
2422
installdirs:
2523
$(mkinstalldirs) $(DESTDIR)$(bindir)
2624

2725
uninstall:
2826
rm -f $(DESTDIR)$(bindir)/pg_config
2927

3028
clean distclean maintainer-clean:
31-
rm -f pg_config
29+
rm -f pg_config$(X) $(OBJS) exec.c

src/bin/pg_config/pg_config.sh

Lines changed: 0 additions & 83 deletions
This file was deleted.

src/include/port.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/port.h,v 1.46 2004/08/01 06:19:24 momjian Exp $
9+
* $PostgreSQL: pgsql/src/include/port.h,v 1.47 2004/08/01 06:56:39 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -44,6 +44,8 @@ extern void get_share_path(const char *my_exec_path, char *ret_path);
4444
extern void get_etc_path(const char *my_exec_path, char *ret_path);
4545
extern void get_include_path(const char *my_exec_path, char *ret_path);
4646
extern void get_pkginclude_path(const char *my_exec_path, char *ret_path);
47+
extern void get_includeserver_path(const char *my_exec_path, char *ret_path);
48+
extern void get_lib_path(const char *my_exec_path, char *ret_path);
4749
extern void get_pkglib_path(const char *my_exec_path, char *ret_path);
4850
extern void get_locale_path(const char *my_exec_path, char *ret_path);
4951
extern void set_pglocale_pgservice(const char *argv0, const char *app);

src/port/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# with broken/missing library files.
88

99
# IDENTIFICATION
10-
# $PostgreSQL: pgsql/src/port/Makefile,v 1.15 2004/05/30 14:07:47 momjian Exp $
10+
# $PostgreSQL: pgsql/src/port/Makefile,v 1.16 2004/08/01 06:56:39 momjian Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -35,6 +35,8 @@ pg_config_paths.h: $(top_builddir)/src/Makefile.global
3535
echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@
3636
echo "#define INCLUDEDIR \"$(includedir)\"" >>$@
3737
echo "#define PKGINCLUDEDIR \"$(pkgincludedir)\"" >>$@
38+
echo "#define INCLUDEDIRSERVER \"$(includedir_server)\"" >>$@
39+
echo "#define LIBDIR \"$(libdir)\"" >>$@
3840
echo "#define PKGLIBDIR \"$(pkglibdir)\"" >>$@
3941
echo "#define LOCALEDIR \"$(localedir)\"" >>$@
4042

src/port/path.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.25 2004/07/12 19:27:31 momjian Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.26 2004/08/01 06:56:39 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -205,10 +205,42 @@ get_pkginclude_path(const char *my_exec_path, char *ret_path)
205205

206206

207207

208+
/*
209+
* get_includeserver_path
210+
*/
211+
void
212+
get_includeserver_path(const char *my_exec_path, char *ret_path)
213+
{
214+
const char *p;
215+
216+
if ((p = relative_path(PGBINDIR, INCLUDEDIRSERVER)))
217+
make_relative(my_exec_path, p, ret_path);
218+
else
219+
StrNCpy(ret_path, INCLUDEDIRSERVER, MAXPGPATH);
220+
canonicalize_path(ret_path);
221+
}
222+
223+
224+
225+
/*
226+
* get_lib_path
227+
*/
228+
void
229+
get_lib_path(const char *my_exec_path, char *ret_path)
230+
{
231+
const char *p;
232+
233+
if ((p = relative_path(PGBINDIR, LIBDIR)))
234+
make_relative(my_exec_path, p, ret_path);
235+
else
236+
StrNCpy(ret_path, LIBDIR, MAXPGPATH);
237+
canonicalize_path(ret_path);
238+
}
239+
240+
241+
208242
/*
209243
* get_pkglib_path
210-
*
211-
* Return library path, either relative to /bin or hardcoded
212244
*/
213245
void
214246
get_pkglib_path(const char *my_exec_path, char *ret_path)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy