# CONFIG.win32-x86-borland.win32-x86-borland
#
# Definitions for win32-x86-borland target arch when host arch is win32-x86-borland
# Sites may override these definitions in CONFIG_SITE.win32-x86-borland.win32-x86-borland
#-------------------------------------------------------

# Win32 valid build types and include directory suffixes

VALID_BUILDS = Host Ioc

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

BORLAND_INC = $(BORLAND)\\include
BORLAND_LIB = $(BORLAND)\\lib
BORLAND_BIN = $(BORLAND)\\bin

#
# "\ " forces gnu make to keep this as one token
#
WINLINK = $(BORLAND_BIN)/ilink32 -q

# -l specifies default language
# -fo Renames the output .RES file
RCCMD = $(BORLAND_BIN)/brcc32 $(subst -I,-i,$(INCLUDES)) -l0x409  -fo$@ $<

ARCMD = $(BORLAND_BIN)/tlib $@   $(foreach lib,$(LIBRARY_LD_OBJS),+$(lib))

#############BAFCMD = bscmake /nologo /o $@

#
# Configure Borland C compiler
# -q suppress compiler identification banner
# -tWM generate a 32-bit multi-threaded target
# -tWD generate a .DLL executable
# -a8 quad word alignment
# -D_WIN32 macro defined to be consistant with Microsoft Visual C++
# -D_RTLDLL macro defined to use Borland C++ RTL library
CCLINKOPT = -q -tWM -tWD -a8 -D_WIN32 -D_RTLDLL
CC = $(BORLAND_BIN)/bcc32 $(CCLINKOPT)
LD = $(BORLAND_BIN)/bcc32 -r
RANLIB =

# -w display warnings on
# -g0 no limit to warning messages
# some warning message here are always disabled because they are
# trivial and numerous
# -w-8012 Comparing signed and unsigned values
# -w-8060 Possibly incorrect assignment
# -w-8071 Conversion may lose significant digits
WARN_CFLAGS_YES = -w -g0 -w-8012 -w-8060 -w-8071
# -w- display warnings off
WARN_CFLAGS_NO =  -w-

#
# -k- turn off standard stack frame
# -H- turn off precompiled headers
# -R- don't include browser info in .obj files
# -O1 optimization for size
# -v- turn off source debugging
# -vi control expansion of inline functions
OPT_CFLAGS_YES = -k- -H- -R- -O1 -v- -vi

#
OPT_CFLAGS_NO =

# OS vendor c preprocessor
CPP = $(BORLAND_BIN)/cpp32  -Sr
PREPROCESS.cpp = $(CPP) $(CPPFLAGS) $(subst /,\\,$(INCLUDES)) -o$@ $<

# Configure OS vendor C++ compiler
CCC = $(BORLAND_BIN)/bcc32 $(CCLINKOPT)

# -w display warnings on
# -g0 no limit to warning messages
# -w-8012 Comparing signed and unsigned values
# -w-8060 Possibly incorrect assignment
# -w-8071 Conversion may lose significant digits
# -w-8008 Condition is always true or always false (compile time 
#           know template parameters causes this to spew garbage)
# -w-8027 Functions containing reserved words are not expanded inline 
#           (Some compilers are better than others with inline)
# -w-8066 Unreachable code (compile time know template parameters
#           causes this to spew garbage)
# -w-8080 'identifier' declared but never used
#           (instantiating unused static const external parameters is 
#           anachronistic compiler practice)
# -w-8004 'identifier' is assigned a value that is never used
#           (compile time know template parameters
#           causes this to spew garbage)
# -w-8026  Functions with exception specifications are not expanded inline
#
WARN_CXXFLAGS_YES = -w -g0 -w-8012 -w-8060 -w-8071 -w-8008 -w-8027 -w-8066 -w-8080 -w-8004 -w-8026
# -w- display warnings off
WARN_CXXFLAGS_NO = -w-

#
# -k- turn off standard stack frame
# -H- Turn off precompiled headers
# -R- Don't include browser info in .obj files
# -O1 optimization for size
# -v- turn off source debugging
# -vi control expansion of inline functions
OPT_CXXFLAGS_YES = -k- -H- -R- -O1 -v- -vi

#
OPT_CXXFLAGS_NO =

#
# no special libs for static link
#
LDLIBS = ws2_32.lib advapi32.lib user32.lib kernel32.lib winmm.lib

# -c case sensitive linking
# -C clear state before linking
# -Gi generate import library
# -Gn no state files
# -Tpd targets a Windows .DLL file
# -x no map
# -w display warnings on
LINK_OPT_FLAGS_YES = -c -C -Gi -Gn -Tpd -x -w
LINK_OPT_FLAGS_NO = -c -C -Gi -Gn -Tpd -x -w-
WIN32_DLLFLAGS = $(LINK_OPT_FLAGS_$(HOST_OPT)) $(TARGET_LDFLAGS) $(LIB_LDFLAGS)
OPT_LDFLAGS =

SHRLIB_CFLAGS=
ARCH_DEP_CFLAGS=

OS_CLASS=WIN32
POSIX=NO

#	ifdef WIN32   looks better that  ifeq ($(OS_CLASS),WIN32)  ??
WIN32=1
BORLANDC=1

EXE=.exe
OBJ=.obj
RES=.res
BAF=.bsc
BOF=.sbr

#       Problem: BorlandC does not recognize  *.cc as C++ source,
#       we have to compile xx.cc  using the flag -P xx.cc,
SOURCE_CXXFLAG = -P -D__cplusplus

#	Operating system flags 
OP_SYS_CFLAGS =

#
# Borland specific include files
#
OP_SYS_INCLUDES = -I$(BORLAND_INC)
#

#
# specify dll .def file only if it exists
#
#DLL_DEF_FLAG = $(addprefix /def:,$(wildcard ../$(addsuffix .def,$(LIBRARY))))
DLL_DEF_FLAG = $(subst /,\\,$(wildcard ../$(addsuffix .def,$*)))

#
#   A WIN32 dll has three parts:
#   x.dll: the real dll (SHRLIBNAME)
#   x.lib: what you link to progs that use the dll (DLL_LINK_LIBNAME)
#   x.exp: what you need to build the dll (in no variable)
#
LINK.shrlib = $(WINLINK) $(WIN32_DLLFLAGS) -L$(BORLAND_LIB) -L$(BORLAND_LIB)\\Psdk c0d32.obj
LINK.shrlib+= $(LIBRARY_LD_OBJS) , $@ ,,$(LINKLIBS)  $(subst /,\\,$(SHRLIB_LDLIBS)),
LINK.shrlib+= $(DLL_DEF_FLAG),$(LIBRARY_LD_RESS)


#	adjust names of libraries to build
#
#	But: if there are no objects LIBRARY_LD_OBJS to include
#	in this library (may be for e.g. base/src/libCompat
#	on some archs), don't define (and build) any library!
SHRLIB_SUFFIX_BASE = .dll
SHRLIB_SUFFIX = $(SHRLIB_SUFFIX_BASE)
SHRLIBNAME_YES = $(BUILD_LIBRARY:%=%$(SHRLIB_SUFFIX))
LOADABLE_SHRLIBNAME = $(LOADABLE_BUILD_LIBRARY:%=%$(SHRLIB_SUFFIX))


# When SHARED_LIBRARIES is YES we are building a DLL link library 
# and when SHARED_LIBRARIES is NO we are building an object library
#
DLL_LINK_LIBNAME_YES = $(BUILD_LIBRARY:%=%.lib)
DLL_LINK_LIBNAME = $(DLL_LINK_LIBNAME_$(SHARED_LIBRARIES))
LIB_PREFIX=
LIB_SUFFIX=.lib
LIBNAME_NO = $(BUILD_LIBRARY:%=%.lib)
LIBNAME = $(LIBNAME_$(SHARED_LIBRARIES))

#	dll install location
INSTALL_SHRLIB = $(INSTALL_BIN)

#--------------------------------------------------
# Products dependancy definitions

# SYS_PROD_LIBS deprecated
# Use PROD_SYS_LIBS

PROD_DEPLIBS=$(foreach lib, $(PROD_LIBS) $(USR_LIBS), \
    $(firstword $(wildcard $(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_SUFFIX), \
    $($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
    $(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_SUFFIX), \
    $(firstword $($(lib)_DIR) $(INSTALL_LIB)))))

PROD_LDLIBS += $($*_DEPLIBS) $(PROD_DEPLIBS)
PROD_LDLIBS += $(addsuffix .lib, \
         $($*_SYS_LIBS) $(PROD_SYS_LIBS) $(USR_SYS_LIBS) )

LDLIBS_STATIC_YES = LDLIBS
LDLIBS_SHARED_NO = LDLIBS
PROD_LDLIBS += $($(firstword $(LDLIBS_STATIC_$(STATIC_BUILD)) \
               $(LDLIBS_SHARED_$(SHARED_LIBRARIES))))

#--------------------------------------------------
#Libraries dependancy definitions

# <name>_DLL_LIBS <name>_SYS_DLL_LIBS deprecated.
# Use <name>_LIBS and <name>_SYS_LIBS.
# DLL_LIBS, and SYS_DLL_LIBS deprecated
# Use LIB_LIBS and LIB_SYS_LIBS
LIB_LIBS += $(DLL_LIBS)
LIB_SYS_LIBS += $(SYS_DLL_LIBS)

#   libs that we need to link the DLL with
#   (it isnt necessary to rebuild the dll if these change)

SHRLIB_DEPLIBS += $(foreach lib, $(LIB_LIBS) $(USR_LIBS), \
    $(firstword $(wildcard $(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_SUFFIX), \
    $($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
    $(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_SUFFIX), \
    $(firstword $($(lib)_DIR) $(INSTALL_LIB)))))

SHRLIB_LDLIBS += $($*_DLL_DEPLIBS) $($*_DEPLIBS) $(SHRLIB_DEPLIBS)
SHRLIB_LDLIBS += $(addsuffix .lib, \
         $($*_SYS_DLL_LIBS) \
         $($*_SYS_LIBS) $(LIB_SYS_LIBS) $(USR_SYS_LIBS) )


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

#multithreaded import library
LIBSUF=mti
# -c case sensitive linking
# -C clear state before linking
# -Gn no state files
# -Tpe targets a Windows .EXE file
# -x no map
# -w display warnings on
LDFLAGS += -c -C -Gn -Tpe -x -w -L$(BORLAND_LIB) -L$(BORLAND_LIB)\\Psdk
LINKSTARTUP = c0x32.obj
LINKLIBS=import32.lib cw32$(LIBSUF).lib

LINK.cpp = $(WINLINK) $(STATIC_LDFLAGS) $(LDFLAGS) $(PROD_LDFLAGS) $(LINKSTARTUP) $(subst /,\\,$(PROD_LD_OBJS))
LINK.cpp += , $@ ,,$(LINKLIBS)  $(subst /,\\,$(PROD_LDLIBS))

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

# override of CONFIG_COMMON
HDEPENDS_INCLUDES_MKMF = $(filter-out $(addprefix -I,$(BORLAND_INC)),$(INCLUDES))


TDS = $(addsuffix .tds,$(basename $(PROD) $(TESTPROD) $(BUILD_LIBRARY)))

