# Makefile for Borland C++

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


!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


# ---------------------------------------------------------------------------
OBJFILES = pqexpbuffer.obj fe-connect.obj fe-exec.obj fe-lobj.obj \
		   fe-misc.obj fe-print.obj fe-auth.obj fe-secure.obj \ 
		   md5.obj dllist.obj win32.obj wchar.obj encnames.obj

DEFFILE = bcc32dll.def

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

# ---------------------------------------------------------------------------
CFLAG = -I..\..\include -WD -c -D$(USERDEFINES) -tWM \
		-q -5 -a8 -pc -X -w-use -w-par -w-pia -w-csu -w-aus -w-ccc

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

LFLAGS = -Gn -L$(INTDIR) -x -Tpd -v

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

.path.obj = $(INTDIR)

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

#ALL: "$(OUTDIR)" "$(OUTDIR)\libpq.dll" "$(OUTDIR)\libpq.lib"
ALL: "$(OUTDIR)" "$(OUTDIR)\libpq.lib"

CLEAN :
	-@erase /S /Q $(INTDIR)
	-@erase /S /Q $(OUTDIR)
	-@rmdir $(INTDIR)
	-@rmdir $(OUTDIR)


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

"$(OUTDIR)\libpq.dll": libpqdll.obj $(OBJFILES)
	ilink32 @&&!
	$(LFLAGS) +
	c0d32.obj $(OBJFILES), +
	$@,, +
	import32.lib cw32mt.lib, +
	$(DEFFILE), +
	$(ALLRES)
!
	implib $(OUTDIR)/libpqdll.lib $@

"$(OUTDIR)\libpq.lib": $(OBJFILES)
	tlib $@ @&&!
+-"$(**: =" &^
+-")"
!

md5.obj: ..\..\backend\libpq\md5.c 
dllist.obj: ..\..\backend\lib\dllist.c
wchar.obj: ..\..\backend\utils\mb\wchar.c
encnames.obj: ..\..\backend\utils\mb\encnames.c

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

.c.obj:
	bcc32 -o"$(INTDIR)\$&" $(CFLAG) $<