Re: Borland c++ compile problems... - Mailing list pgsql-hackers-win32

From Steve Holdoway
Subject Re: Borland c++ compile problems...
Date
Msg-id 40FF0A57.8080002@treshna.com
Whole thread Raw
In response to Re: Borland c++ compile problems...  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Borland c++ compile problems...
Re: Borland c++ compile problems...
List pgsql-hackers-win32
Bruce Momjian wrote:

>Steve Holdoway wrote:
>  
>
>>Bruce Momjian wrote:
>>
>>    
>>
>>>Steve Holdoway wrote:
>>> 
>>>
>>>      
>>>
>>>>Sorry to be a pest, and all that. However, it looks like make needs to 
>>>>be run in src\port, to create pg_config_paths.h, and compile stuff to 
>>>>resolve externals _set_noblock, _pg_strcasecmp, _pg_tolower, and _popen 
>>>>(? bit worried about that one!)
>>>>
>>>>I had a go at rewriting an existing bcc32.mak, but just seemed to 
>>>>generate more errors!
>>>>   
>>>>
>>>>        
>>>>
>>>Uh, I don't see how those would fail.  What errors are you seeing?
>>>
>>> 
>>>
>>>      
>>>
>>Well, in the port subdirectory, one of the things that is generated by 
>>the makefile is pg_config_paths.h. Without this, libpq will not compile. 
>>As I stated above, cobbling this together manually then gets me to the 
>>place where the aforementioned external references are not resolved. All 
>>are in source files in the port directory.
>>
>>The errors I'm seeing are all caused by includes not being found, etc. I 
>>don't know what to do when they are ones like strings.h, which I do not 
>>have either in the snapshot source tree, or in the Borland bcc 5.5 tree.
>>
>>I also don't know how you want the above files building... into a 
>>library, static or dynamic/straight object code, etc. There is also no 
>>listing in the current bcc32.mak files to include them into the libpq 
>>dll generation.
>>    
>>
>
>OK, if you look at the last few commits to interfaces/libpq/win32.mak,
>you will see changes for pg_config_paths.h and for thread safety.  Can
>you look at those changes, merge them into bcc.mak.  There might be
>other changes in there you want to add to bcc.mak too.
>
>  
>
OK, having no M$ diff, I attach files src\interfaces\libpq\bcc32.mak and 
src\interfaces\libpq\win32.h

bcc32.mak incorporates the changes in win32.mak, and adds a couple of 
extra source files from the ..\..\port directory, and win32.h was used 
to #define popen -> _popen.

All seems to work after a *very* cursory test!

Can I get back to the land of proper slashes now???

Cheers,

Steve
# Makefile for Borland C++ 5.5

# Will build a Win32 static library libpq.lib
#        and a Win32 dynamic library libpq.dll with import library libpqdll.lib

# Borland C++ base install directory goes here
BCB=c:\Borland\Bcc55

!MESSAGE Building the Win32 DLL and Static Library...
!MESSAGE
!IF "$(CFG)" == ""
CFG=Release
!MESSAGE No configuration specified. Defaulting to Release.
!MESSAGE
!ELSE
!MESSAGE Configuration "$(CFG)"
!MESSAGE
!ENDIF

!IF "$(CFG)" != "Release" && "$(CFG)" != "Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running MAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE make  -DCFG=[Release | Debug] /f bcc32.mak
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Release" (Win32 Release DLL and Static Library)
!MESSAGE "Debug" (Win32 Debug DLL and Static Library)
!MESSAGE
!ERROR An invalid configuration was specified.
!ENDIF

!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE 
NULL=nul
!ENDIF 

!IF "$(CFG)" == "Debug"
DEBUG=1
OUTDIR=.\Debug
INTDIR=.\Debug
!else
OUTDIR=.\Release
INTDIR=.\Release
!endif

USERDEFINES=FRONTEND;NDEBUG;WIN32;_WINDOWS;HAVE_VSNPRINTF;HAVE_STRDUP;

CPP=bcc32.exe
CPP_PROJ = -I$(BCB)\include;..\..\include -WD -c -D$(USERDEFINES) -tWM \
        -a8 -X -w-use -w-par -w-pia -w-csu -w-aus -w-ccc

!IFDEF DEBUG
CPP_PROJ    = $(CPP_PROJ) -Od -r- -k -v -y -vi- -D_DEBUG
!else
CPP_PROJ        = $(CPP_PROJ) -O -Oi -OS -DNDEBU
!endif

LIB32=tlib.exe
LIB32_FLAGS= 
LIB32_OBJS= \
    "$(OUTDIR)\win32.obj" \
    "$(INTDIR)\getaddrinfo.obj" \
    "$(INTDIR)\thread.obj" \
    "$(INTDIR)\inet_aton.obj" \
    "$(INTDIR)\crypt.obj" \
    "$(INTDIR)\path.obj" \
        "$(INTDIR)\noblock.obj" \
        "$(INTDIR)\pgstrcasecmp.obj" \
    "$(INTDIR)\dllist.obj" \
    "$(INTDIR)\md5.obj" \
    "$(INTDIR)\ip.obj" \
    "$(INTDIR)\fe-auth.obj" \
    "$(INTDIR)\fe-protocol2.obj" \
    "$(INTDIR)\fe-protocol3.obj" \
    "$(INTDIR)\fe-connect.obj" \
    "$(INTDIR)\fe-exec.obj" \
    "$(INTDIR)\fe-lobj.obj" \
    "$(INTDIR)\fe-misc.obj" \
    "$(INTDIR)\fe-print.obj" \
    "$(INTDIR)\fe-secure.obj" \
    "$(INTDIR)\pqexpbuffer.obj" \
    "$(INTDIR)\wchar.obj" \
        "$(INTDIR)\encnames.obj"


RSC=brcc32.exe
RSC_PROJ=-l 0x409 -i$(BCB)\include -fo"$(INTDIR)\libpq.res"

LINK32=ilink32.exe
LINK32_FLAGS = -Gn -L$(BCB)\lib;$(INTDIR); -x -Tpd -v
LINK32_OBJS= "$(INTDIR)\libpqdll.obj"
    
# ---------------------------------------------------------------------------

.path.obj = $(INTDIR)
.path.c = .;..\..\port;..\..\backend\libpq;..\..\backend\lib;..\..\backend\utils\mb

# ---------------------------------------------------------------------------

ALL: config "$(OUTDIR)" "$(OUTDIR)\blibpq.dll" "$(OUTDIR)\blibpq.lib"

CLEAN :
    -@erase "$(INTDIR)\getaddrinfo.obj"
    -@erase "$(INTDIR)\thread.obj"
    -@erase "$(INTDIR)\inet_aton.obj"
    -@erase "$(INTDIR)\crypt.obj"
    -@erase "$(INTDIR)\path.obj"
    -@erase "$(INTDIR)\dllist.obj"
    -@erase "$(INTDIR)\md5.obj"
    -@erase "$(INTDIR)\ip.obj"
    -@erase "$(INTDIR)\fe-auth.obj"
    -@erase "$(INTDIR)\fe-protocol2.obj"
    -@erase "$(INTDIR)\fe-protocol3.obj"
    -@erase "$(INTDIR)\fe-connect.obj"
    -@erase "$(INTDIR)\fe-exec.obj"
    -@erase "$(INTDIR)\fe-lobj.obj"
    -@erase "$(INTDIR)\fe-misc.obj"
    -@erase "$(INTDIR)\fe-print.obj"
    -@erase "$(INTDIR)\fe-secure.obj"
    -@erase "$(INTDIR)\pqexpbuffer.obj"
    -@erase "$(OUTDIR)\libpqdll.obj"
    -@erase "$(OUTDIR)\win32.obj"
    -@erase "$(INTDIR)\wchar.obj"
    -@erase "$(INTDIR)\encnames.obj"
        -@erase "$(INTDIR)\noblock.obj"
        -@erase "$(INTDIR)\pgstrcasecmp.obj"
    -@erase "$(OUTDIR)\libpq.res"
    -@erase "$(OUTDIR)\blibpq.lib"
    -@erase "$(OUTDIR)\blibpqdll.lib"
    -@erase "$(OUTDIR)\blibpq.dll"
    -@erase "$(OUTDIR)\blibpq.tds"

config: ..\..\include\pg_config.h pthread.h pg_config_paths.h

..\..\include\pg_config.h: ..\..\include\pg_config.h.win32
    copy ..\..\include\pg_config.h.win32 ..\..\include\pg_config.h

pthread.h: pthread.h.win32
    copy pthread.h.win32 pthread.h

pg_config_paths.h: win32.mak
    echo #define SYSCONFDIR "" >pg_config_paths.h

"$(OUTDIR)" :
    @if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"

"$(OUTDIR)\blibpq.dll": "$(OUTDIR)\blibpq.lib" $(LINK32_OBJS) "$(INTDIR)\libpq.res" blibpqdll.def 
    $(LINK32) @&&!
    $(LINK32_FLAGS) +
        c0d32.obj $(LINK32_OBJS), +
    $@,, +
        "$(OUTDIR)\blibpq.lib" import32.lib cw32mti.lib, +
    blibpqdll.def,"$(INTDIR)\libpq.res"
!
    implib -w "$(OUTDIR)\blibpqdll.lib" blibpqdll.def $@

"$(INTDIR)\libpq.res" : "$(INTDIR)" libpq.rc
    $(RSC) $(RSC_PROJ) libpq.rc

"$(OUTDIR)\blibpq.lib": $(LIB32_OBJS)
    $(LIB32) $@ @&&!
+-"$(**: =" &^
+-")"
!


.c.obj:
    $(CPP) -o"$(INTDIR)\$&" $(CPP_PROJ) $<

#ifndef __win32_h_included
#define __win32_h_included

/*
 * Some compatibility functions
 */
#ifdef __BORLANDC__
#define _timeb timeb
#define _ftime(a) ftime(a)
#define _errno errno
#define popen(a,b) _popen(a,b)
#else
/* open provided elsewhere */
#define close(a) _close(a)
#define read(a,b,c) _read(a,b,c)
#define write(a,b,c) _write(a,b,c)
#endif

#define vsnprintf(a,b,c,d) _vsnprintf(a,b,c,d)
#define snprintf _snprintf

#undef EAGAIN                    /* doesn't apply on sockets */
#undef EINTR
#define EINTR WSAEINTR
#define EWOULDBLOCK WSAEWOULDBLOCK
#define ECONNRESET WSAECONNRESET
#define EINPROGRESS WSAEINPROGRESS

/*
 * support for handling Windows Socket errors
 */
extern const char *winsock_strerror(int err, char *strerrbuf, size_t buflen);

#endif

pgsql-hackers-win32 by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Borland c++ compile problems...
Next
From: Claudio Natoli
Date:
Subject: Re: win2k, service, pg_ctl, popen, etc