Re: utils C files - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: utils C files
Date
Msg-id 200207180359.g6I3xS517133@candle.pha.pa.us
Whole thread Raw
In response to Re: utils C files  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > How is this any better than just mentioning the *.o file and letting the
> > default rules compile it.  I don't understand how linking to the current
> > directory gets us anything.  Now, if you did a 'make -C dir target' that
> > would be different.
>
> The whole point of the pushups for libpq is that we DON'T want the
> default rules.  We need to compile it PIC so that it can go into a
> shared library.  This will not be the same object file built in the
> ports directory.

OK, this cleanup makes the src/backend/port file location dependent only
on configure.in values.  I will now move them from src/backend/port to
src/port.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: contrib/pg_controldata/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_controldata/Makefile,v
retrieving revision 1.5
diff -c -r1.5 Makefile
*** contrib/pg_controldata/Makefile    6 Sep 2001 10:49:29 -0000    1.5
--- contrib/pg_controldata/Makefile    18 Jul 2002 03:58:46 -0000
***************
*** 5,18 ****
  include $(top_builddir)/src/Makefile.global

  PROGRAM = pg_controldata
! OBJS    = pg_controldata.o pg_crc.o $(SNPRINTF)

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .

! # this only gets done if configure finds system doesn't have snprintf()
! snprintf.c: $(top_srcdir)/src/backend/port/snprintf.c
      rm -f $@ && $(LN_S) $< .

  EXTRA_CLEAN = pg_crc.c snprintf.c

--- 5,19 ----
  include $(top_builddir)/src/Makefile.global

  PROGRAM = pg_controldata
! OBJS    = pg_controldata.o pg_crc.o $(notdir $(SNPRINTF))

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .

! ifdef SNPRINTF
! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c
      rm -f $@ && $(LN_S) $< .
+ endif

  EXTRA_CLEAN = pg_crc.c snprintf.c

Index: contrib/pg_resetxlog/Makefile
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_resetxlog/Makefile,v
retrieving revision 1.3
diff -c -r1.3 Makefile
*** contrib/pg_resetxlog/Makefile    6 Sep 2001 10:49:30 -0000    1.3
--- contrib/pg_resetxlog/Makefile    18 Jul 2002 03:58:46 -0000
***************
*** 5,18 ****
  include $(top_builddir)/src/Makefile.global

  PROGRAM = pg_resetxlog
! OBJS    = pg_resetxlog.o pg_crc.o $(SNPRINTF)

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .

! # this only gets done if configure finds system doesn't have snprintf()
! snprintf.c: $(top_srcdir)/src/backend/port/snprintf.c
      rm -f $@ && $(LN_S) $< .

  EXTRA_CLEAN = pg_crc.c snprintf.c

--- 5,19 ----
  include $(top_builddir)/src/Makefile.global

  PROGRAM = pg_resetxlog
! OBJS    = pg_resetxlog.o pg_crc.o $(notdir $(SNPRINTF))

  pg_crc.c: $(top_srcdir)/src/backend/utils/hash/pg_crc.c
      rm -f $@ && $(LN_S) $< .

! ifdef SNPRINTF
! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c
      rm -f $@ && $(LN_S) $< .
+ endif

  EXTRA_CLEAN = pg_crc.c snprintf.c

Index: src/interfaces/libpq/Makefile
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v
retrieving revision 1.62
diff -c -r1.62 Makefile
*** src/interfaces/libpq/Makefile    14 Jun 2002 04:23:17 -0000    1.62
--- src/interfaces/libpq/Makefile    18 Jul 2002 03:58:48 -0000
***************
*** 12,17 ****
--- 12,18 ----
  top_builddir = ../../..
  include $(top_builddir)/src/Makefile.global

+
  # shared library parameters
  NAME= pq
  SO_MAJOR_VERSION= 2
***************
*** 21,32 ****

  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
        pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \
!       $(INET_ATON) $(SNPRINTF) $(STRERROR)

  ifdef MULTIBYTE
  OBJS+= wchar.o encnames.o
  endif

  # Add libraries that libpq depends (or might depend) on into the
  # shared library link.  (The order in which you list them here doesn't
  # matter.)
--- 22,34 ----

  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
        pqexpbuffer.o dllist.o md5.o pqsignal.o fe-secure.o \
!       $(notdir $(INET_ATON)) $(notdir $(SNPRINTF)) $(notdir $(STRERROR))

  ifdef MULTIBYTE
  OBJS+= wchar.o encnames.o
  endif

+
  # Add libraries that libpq depends (or might depend) on into the
  # shared library link.  (The order in which you list them here doesn't
  # matter.)
***************
*** 37,68 ****

  # Shared library stuff
  include $(top_srcdir)/src/Makefile.shlib
-
-
- # We use several backend modules verbatim, but since we need to
- # compile with appropriate options to build a shared lib, we can't
- # necessarily use the same object files as the backend uses. Instead,
- # symlink the source files in here and build our own object file.
-
  backend_src = $(top_srcdir)/src/backend

  dllist.c: $(backend_src)/lib/dllist.c
      rm -f $@ && $(LN_S) $< .

  md5.c: $(backend_src)/libpq/md5.c
      rm -f $@ && $(LN_S) $< .

  # this only gets done if configure finds system doesn't have inet_aton()
! inet_aton.c: $(backend_src)/port/inet_aton.c
      rm -f $@ && $(LN_S) $< .

! # this only gets done if configure finds system doesn't have snprintf()
! snprintf.c: $(backend_src)/port/snprintf.c
      rm -f $@ && $(LN_S) $< .

! # this only gets done if configure finds system doesn't have strerror()
! strerror.c: $(backend_src)/port/strerror.c
      rm -f $@ && $(LN_S) $< .

  ifdef MULTIBYTE
  wchar.c : % : $(backend_src)/utils/mb/%
--- 39,73 ----

  # Shared library stuff
  include $(top_srcdir)/src/Makefile.shlib
  backend_src = $(top_srcdir)/src/backend

+
  dllist.c: $(backend_src)/lib/dllist.c
      rm -f $@ && $(LN_S) $< .

  md5.c: $(backend_src)/libpq/md5.c
      rm -f $@ && $(LN_S) $< .

+ # We use several backend modules verbatim, but since we need to
+ # compile with appropriate options to build a shared lib, we can't
+ # necessarily use the same object files as the backend uses. Instead,
+ # symlink the source files in here and build our own object file.
  # this only gets done if configure finds system doesn't have inet_aton()
!
! ifdef INET_ATON
! $(basename $(notdir $(INET_ATON))).c: $(basename $(INET_ATON)).c
      rm -f $@ && $(LN_S) $< .
+ endif

! ifdef SNPRINTF
! $(basename $(notdir $(SNPRINTF))).c: $(basename $(SNPRINTF)).c
      rm -f $@ && $(LN_S) $< .
+ endif

! ifdef STRERROR
! $(basename $(notdir $(STRERROR))).c: $(basename $(STRERROR)).c
      rm -f $@ && $(LN_S) $< .
+ endif

  ifdef MULTIBYTE
  wchar.c : % : $(backend_src)/utils/mb/%

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: utils C files
Next
From: Bruce Momjian
Date:
Subject: Re: utils C files