Re: BCC55 and libpq 8.2 - Mailing list pgsql-interfaces

From Bruce Momjian
Subject Re: BCC55 and libpq 8.2
Date
Msg-id 200701060157.l061v0A19508@momjian.us
Whole thread Raw
In response to Re: BCC55 and libpq 8.2  (L Bayuk <lbayuk@pobox.com>)
Responses Re: BCC55 and libpq 8.2
List pgsql-interfaces
I have created the following patch based on your description of how to
get BCC compiled.  Please let me know how it works against a stock
PostgreSQL 8.2.X and I can include the patch in 8.2.2.  Sorry it didn't
make it in time for 8.2.1.

---------------------------------------------------------------------------

L Bayuk wrote:
> On Wed, Dec 20, 2006 at 07:51:00PM +0100, fabio guidi wrote:
> >...
> > Hello to all, i'm trying to build libpq for postgresql 8.2 with borland
> > bcc5.5
> > ...
>
> I finally found myself in front of Windows PC, with PostgreSQL-8.2.0
> source, Borland BCC32 compiler, and a little time. I was trying to build my
> Pgtclng DLL (http://pgfoundry.org/projects/pgtclng/) which requires the
> libpq DLL.  The bad news is that (as you found) a bunch of stuff got broken
> in 8.2.0 regarding BCC builds of libpq.  The good news is that I succeeded.
> I built the libpq DLL, my Pgtclng DLL, and even the psql program. I tested
> Pgtclng pretty hard with my test suite and it passed, so I am confident the
> libpq build was good in so far as Pgtclng uses it.  But it got some scary
> compiler warnings that I still want to look into.
>
> I will try to post a patch soon for the bcc32.mak files, but I also had to
> change some other files used by all other builds and I can't see them
> patching those files for BCC. I don't have patch files yet, but if you want
> to try it yourself here are the details.  Unless I missed something, after
> these changes "make -N -f bcc32.mak" inside interfaces/libpq should build
> it for you. There are also a few fixes for building psql I have to post
> some other time. Sorry I don't have this as a patch yet but I figured you
> have waited long enough and might want to try it.
>
> In include/c.h :
>   Change: #if defined(__BORLANDC__) || (_MSC_VER >= 1400)
>       to: #if (_MSC_VER >= 1400)
>
> In include/port.h :
>  Delete the random() declaration, or change it so it looks like this:
>      #if !defined(__BORLANDC__)
>      #ifndef HAVE_RANDOM
>      extern long random(void);
>      #endif
>      #endif
>
> In include/, copy pg_config.h.win32 to pg_config.h
> In include/, copy port/win32.h to pg_config_os.h and make the following
> changes. I made these conditional on __BORLANDC__, but if you are only
> trying to build the thing just delete or change these lines:
>    Remove #include <sys/utime.h>
>    Remove #define SIGUSR1 and SIGUSR2.
>    Remove declarations of ssize_t and mode_t.
>    Remove #define's of _S_IRWXU through S_ISREG.
>    Replace the definitions so inline and __inline__ are defined to nothing.
>     (Might not be necessary, but it was in my notes from prior releases.)
>
> In interfaces/libpq/bcc32.mak:
>    Add "snprintf.obj" to the LIB32_OBJS macro, and add the block which
>       builds it: Copy the applicable lines from win32.mak.
>    I always had to make these two changes to bcc32.mak for Pgtclng, but
>    this could be specific to linking with Tcl so you might not need it.
>       1) Add -c to LINK32_FLAGS (makes it case sensitive).
>       2) Change runtime library from cw32mti.lib to cw32mt.lib (static version)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq

--
  Bruce Momjian   bruce@momjian.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/c.h,v
retrieving revision 1.215
diff -c -c -r1.215 c.h
*** src/include/c.h    5 Jan 2007 22:19:50 -0000    1.215
--- src/include/c.h    6 Jan 2007 01:40:05 -0000
***************
*** 59,65 ****
  #include "postgres_ext.h"
  #include "pg_trace.h"

! #if defined(__BORLANDC__) || (_MSC_VER >= 1400)
  #define errcode __msvc_errcode
  #include <crtdefs.h>
  #undef errcode
--- 59,65 ----
  #include "postgres_ext.h"
  #include "pg_trace.h"

! #if _MSC_VER >= 1400
  #define errcode __msvc_errcode
  #include <crtdefs.h>
  #undef errcode
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port.h,v
retrieving revision 1.107
diff -c -c -r1.107 port.h
*** src/include/port.h    5 Jan 2007 22:19:50 -0000    1.107
--- src/include/port.h    6 Jan 2007 01:40:05 -0000
***************
*** 343,349 ****
  extern size_t strlcpy(char *dst, const char *src, size_t siz);
  #endif

! #ifndef HAVE_RANDOM
  extern long random(void);
  #endif

--- 343,349 ----
  extern size_t strlcpy(char *dst, const char *src, size_t siz);
  #endif

! #if !defined(HAVE_RANDOM) && !defined(__BORLANDC__)
  extern long random(void);
  #endif

Index: src/include/port/win32.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/port/win32.h,v
retrieving revision 1.64
diff -c -c -r1.64 win32.h
*** src/include/port/win32.h    2 Jan 2007 21:25:50 -0000    1.64
--- src/include/port/win32.h    6 Jan 2007 01:40:05 -0000
***************
*** 17,23 ****
--- 17,25 ----
  #include <signal.h>
  #include <errno.h>
  #include <direct.h>
+ #ifndef __BORLANDC__
  #include <sys/utime.h>            /* for non-unicode version */
+ #endif
  #undef near

  /* Must be here to avoid conflicting with prototype in windows.h */
***************
*** 149,156 ****
--- 151,160 ----
  #define SIGTTIN                21
  #define SIGTTOU                22    /* Same as SIGABRT -- no problem, I hope */
  #define SIGWINCH            28
+ #ifndef __BORLANDC__
  #define SIGUSR1                30
  #define SIGUSR2                31
+ #endif

  struct timezone
  {
***************
*** 258,266 ****


  /* Things that exist in MingW headers, but need to be added to MSVC */
! #ifdef WIN32_ONLY_COMPILER
  typedef long ssize_t;
  typedef unsigned short mode_t;

  /*
   *    Certain "standard edition" versions of MSVC throw a warning
--- 262,271 ----


  /* Things that exist in MingW headers, but need to be added to MSVC */
! #if defined(WIN32_ONLY_COMPILER) && !defined(__BORLANDC__)
  typedef long ssize_t;
  typedef unsigned short mode_t;
+ #endif

  /*
   *    Certain "standard edition" versions of MSVC throw a warning
***************
*** 271,276 ****
--- 276,282 ----
  #define inline __inline
  #define __inline__ __inline

+ #ifndef __BORLANDC__
  #define _S_IRWXU    (_S_IREAD | _S_IWRITE | _S_IEXEC)
  #define _S_IXUSR    _S_IEXEC
  #define _S_IWUSR    _S_IWRITE
***************
*** 280,285 ****
--- 286,292 ----
  #define S_IXUSR        _S_IXUSR
  #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+ #endif

  #define F_OK 0
  #define W_OK 2
Index: src/interfaces/libpq/bcc32.mak
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/bcc32.mak,v
retrieving revision 1.25
diff -c -c -r1.25 bcc32.mak
*** src/interfaces/libpq/bcc32.mak    21 Nov 2006 23:26:47 -0000    1.25
--- src/interfaces/libpq/bcc32.mak    6 Jan 2007 01:40:05 -0000
***************
*** 76,82 ****
  CLEAN :
      -@erase "$(INTDIR)\getaddrinfo.obj"
      -@erase "$(INTDIR)\pgstrcasecmp.obj"
-     -@erase "$(INTDIR)\strlcpy.obj"
      -@erase "$(INTDIR)\thread.obj"
      -@erase "$(INTDIR)\inet_aton.obj"
      -@erase "$(INTDIR)\crypt.obj"
--- 76,81 ----
***************
*** 99,104 ****
--- 98,105 ----
      -@erase "$(INTDIR)\wchar.obj"
      -@erase "$(INTDIR)\encnames.obj"
      -@erase "$(INTDIR)\pthread-win32.obj"
+     -@erase "$(INTDIR)\snprintf.obj"
+     -@erase "$(INTDIR)\strlcpy.obj"
      -@erase "$(OUTDIR)\$(OUTFILENAME).lib"
      -@erase "$(OUTDIR)\$(OUTFILENAME)dll.lib"
      -@erase "$(OUTDIR)\libpq.res"
***************
*** 113,119 ****
      "$(INTDIR)\win32.obj" \
      "$(INTDIR)\getaddrinfo.obj" \
      "$(INTDIR)\pgstrcasecmp.obj" \
-     "$(INTDIR)\strlcpy.obj" \
      "$(INTDIR)\thread.obj" \
      "$(INTDIR)\inet_aton.obj" \
      "$(INTDIR)\crypt.obj" \
--- 114,119 ----
***************
*** 133,138 ****
--- 133,140 ----
      "$(INTDIR)\pqsignal.obj" \
      "$(INTDIR)\wchar.obj" \
      "$(INTDIR)\encnames.obj" \
+     "$(INTDIR)\snprintf.obj" \
+     "$(INTDIR)\strlcpy.obj" \
      "$(INTDIR)\pthread-win32.obj"


***************
*** 187,197 ****
      $(CPP_PROJ) ..\..\port\pgstrcasecmp.c
  <<

- "$(INTDIR)\strlcpy.obj" : ..\..\port\strlcpy.c
-     $(CPP) @<<
-     $(CPP_PROJ) ..\..\port\strlcpy.c
- <<
-
  "$(INTDIR)\thread.obj" : ..\..\port\thread.c
      $(CPP) @<<
      $(CPP_PROJ) ..\..\port\thread.c
--- 189,194 ----
***************
*** 233,237 ****
--- 230,244 ----
      $(CPP_PROJ) /I"." ..\..\backend\utils\mb\encnames.c
  <<

+ "$(INTDIR)\snprintf.obj" : ..\..\port\snprintf.c
+     $(CPP) @<<
+     $(CPP_PROJ) ..\..\port\snprintf.c
+ <<
+
+ "$(INTDIR)\strlcpy.obj" : ..\..\port\strlcpy.c
+     $(CPP) @<<
+     $(CPP_PROJ) ..\..\port\strlcpy.c
+ <<
+
  .c.obj:
      $(CPP) $(CPP_PROJ) $<
Index: src/interfaces/libpq/win32.mak
===================================================================
RCS file: /cvsroot/pgsql/src/interfaces/libpq/win32.mak,v
retrieving revision 1.42
diff -c -c -r1.42 win32.mak
*** src/interfaces/libpq/win32.mak    21 Nov 2006 23:26:47 -0000    1.42
--- src/interfaces/libpq/win32.mak    6 Jan 2007 01:40:05 -0000
***************
*** 74,81 ****
      -@erase "$(OUTDIR)\$(OUTFILENAME)dll.lib"
      -@erase "$(OUTDIR)\libpq.res"
      -@erase "$(OUTDIR)\$(OUTFILENAME).dll"
- #    -@erase "*.pch"
- #    -@erase "$(OUTDIR)\libpq.pch"
      -@erase "$(OUTDIR)\$(OUTFILENAME)dll.exp"
      -@erase "$(INTDIR)\pg_config_paths.h"

--- 74,79 ----

pgsql-interfaces by date:

Previous
From: L Bayuk
Date:
Subject: BCC-built psql does not work
Next
From: L Bayuk
Date:
Subject: Re: BCC55 and libpq 8.2