1# pgtclng/Makefile for Borland C++ 5.5
2# $Id: bcc32.mak 272 2011-03-24 00:22:40Z lbayuk $
3#  This originally started from the win32.mak (MS VC++ makefile) but has
4# been rewritten using H.G.'s sample files and a lot of simplification.
5#
6# This builds a stubs-enabled DLL for pgtcl-ng. If you want a non-stubs-
7# enabled version, as was done with pgtclng-1.7.0 and older, remove the
8# definition of USE_TCL_STUBS and change the TCLLIB definition below.
9#
10# This assumes your PATH includes the Borland BCC bin directory, so
11# it can find MAKE, and that your bcc32.cfg/ilink32.cfg files were
12# created (in the Borland bin directory) per the installation notes,
13# so it can find the include files and libraries.
14
15# Release version, needed by the source code.
16MAJOR_VERSION=1
17MINOR_VERSION=7
18PATCHLEVEL=.2
19VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)$(PATCHLEVEL)
20
21# Path to Borland compiler installation base directory:
22BORLAND=c:\apps\bcc
23# Path to Tcl installation base directory:
24TCL=c:\apps\tcl
25# Path to top-level PostgreSQL source directory (src/ in the distribution):
26POSTGRESQL=c:\src\pgsql\src
27# Path to PostgreSQL libpq source directory:
28LIBPQ=$(POSTGRESQL)\interfaces\libpq
29# Path to libpq build directory:
30LIBPQDIR=$(LIBPQ)\Release
31
32# Commands:
33LINK=ilink32
34
35# Include paths:
36INCLUDES=-I$(POSTGRESQL)\include -I$(LIBPQ) -I$(TCL)\include
37# Library path:
38LIBDIRS=-L$(TCL)\lib -L$(LIBPQDIR)
39
40# Tcl Stubs library: This is built from tclstublib.c using BCC.
41TCLLIB=tclstub85bcc.lib
42STUBS=-DUSE_TCL_STUBS
43# If you do not want a stubs-enabled DLL, or can't build the above file, you
44# can make a non-stubs-enabled version of pgtclng. Comment out the two lines
45# above this comment, and uncomment these.  Use coff2omf (included with BCC)
46# to convert the Tcl library tcl85.lib to tcl85omf.lib.
47# Tcl Library name, non-stubs: This is converted with coff2omf.
48#TCLLIB=tcl85omf.lib
49#STUBS=
50
51# PostgreSQL libpq export library name - this was directly built with bcc:
52PGLIB=blibpqdll.lib
53# PostgreSQL libpq loadable library
54PGDLL=blibpq.dll
55# If you are building with a version older than PostgreSQL-8.3.0 you
56# may need to undefine some of these.
57PGDEFS=$(STUBS) \
58 -DHAVE_LO_TRUNCATE=1\
59 -DHAVE_PQDESCRIBEPREPARED=1\
60 -DHAVE_PQENCRYPTPASSWORD=1\
61 -DHAVE_PQESCAPEBYTEACONN=1\
62 -DHAVE_PQESCAPESTRINGCONN=1
63
64# Destination for "make install":
65DEST=$(TCL)\lib\Pgtcl$(VERSION)
66
67# Compiler flags and preprocessor defines - uncomment one set for debug/release:
68# Compiler flags for no-debug:
69CCFLAGS=-5 -d -WD -tWM -c -v- -vi- -w -O2 -OS -a8 -w-par -w-pia
70# -5 : Generate Pentium instructions
71# -d : merge duplicate strings
72# -WD : Target is a DLL
73# -tWM : Multi-threaded target
74# -c : Compile to .obj without linking
75# -v- : Don't enable source debugging
76# -vi- : Don't expand inline functions
77# -O2 : Optimize for speed
78# -OS : Pentium instruction scheduling
79# -a8 : 8-byte alignment (default is 4)
80# -w : Display warnings on
81# -w-par : Omit warning: parameter not used (Tcl procs have a lot)
82# -w-pia : Omit warning: possibly incorrect assignment, because bcc doesn't
83#          honor the double parens ((a = exp)) hint.
84# Compiler preprocessor defines:
85DEFINES=-DNDEBUG -DWIN32 -D_WINDOWS -D_USRDLL $(PGDEFS) -DVERSION=\"$(VERSION)\"
86#
87# Compiler flags for debugging:
88#CCFLAGS=-5 -d -WD -c -r- -v -vi- -y -w -Od -a8 -w-par -w-pia
89#  -r- : do not use register vars
90#  -v : turn on debug
91#  -vi- : No inline expansion
92#  -y : turn on line numbers
93#  -Od : no optimization
94#    Omit -OS Pentium scheduling
95# Compiler preprocessor defines:
96#DEFINES=-D_DEBUG -DWIN32 -D_WINDOWS -D_USRDLL $(PGDEFS) -DVERSION=\"$(VERSION)\"
97
98# Linker flags and startup file (c0d32):
99LINKFLAGS=$(LIBDIRS) -ap -Tpd -c -Gn $(BORLAND)\lib\c0d32.obj
100# -ap : Build a 32-bit Windows console app (vs -aa, a Windows app)
101# -Tpd : Targets a Windows DLL file
102# -c : Treats case as significant in symbols
103# -Gn : Don't make files for incremental link.
104# Linker libraries:
105# Note: cw32mt is multi-threaded static RTL. Don't use cw32mti (multi-threaded
106# import RTL), because fprintf will crash.
107LINKLIBS=$(TCLLIB) $(PGLIB) import32.lib cw32mt.lib
108
109# Combined compiler flags/options used by default .c.obj rule:
110CFLAGS=$(DEFINES) $(INCLUDES) $(CCFLAGS)
111
112# List of objects making up the target:
113OBJS=pgtcl.obj pgtclCmds.obj pgtclId.obj
114
115# Default thing to build:
116TARGET=libpgtcl
117all: $(TARGET).dll
118
119# Things to build:
120$(TARGET).dll: $(OBJS)
121	$(LINK) $(LINKFLAGS) $(OBJS),$@,-x,$(LINKLIBS),,
122
123# Source and header dependencies:
124pgtcl.obj: pgtcl.c libpgtcl.h pgtclCmds.h pgtclId.h
125pgtclCmds.obj: pgtclCmds.c pgtclCmds.h pgtclId.h
126pgtclId.obj: pgtclId.c pgtclCmds.h pgtclId.h
127
128# Install Pgtcl as a loadable package:
129install: $(TARGET).dll
130	-mkdir $(DEST)
131	copy $(LIBPQDIR)\$(PGDLL) $(DEST)
132	copy $(TARGET).dll $(DEST)
133	copy pkgIndex.tcl.win32 $(DEST)\pkgIndex.tcl
134
135# Cleanup: Remove all but the target DLL
136clean:
137	-del $(OBJS)
138	-del $(TARGET).tds
139	-del $(TARGET).il?
140