# 
# $Id$
#
# The Harbour Project
# GNU MAKE file for Borland C/C++ 32bit (4.x, 5.x)

include $(TOP)$(ROOT)config/$(HB_ARCHITECTURE)/global.cf

OBJ_EXT = .obj
EXE_EXT = .exe
LIB_PREF =
LIB_EXT = .lib

_HB_INC_COMPILE = $(subst /,\,$(HB_INC_COMPILE))
_HL = $(notdir $(HB_LIB_COMPILE))
ifeq ($(_HL),)
#there is an ending slash
_HB_LIB_COMPILE = $(subst /,\,$(HB_LIB_COMPILE))
else
_HB_LIB_COMPILE = $(subst /,\,$(HB_LIB_COMPILE)/)
endif

CC = bcc32
CC_IN = -c
CC_OUT = -o
CPPFLAGS = -I$(GRANDP) -I$(HB_INC_COMPILE)
CFLAGS = -O2 -d

LD = bcc32
LDFLAGS = -O2
LD_OUT = -e

# Add all libraries specified in LIBS.
ifeq ($(HB_LIB_COMPILE),)
LINKLIBS += $(foreach lib, $(LIBS), $(TOP)$(ROOT)/source/$(lib)/$(ARCH)/$(lib)$(LIB_EXT))
else
LINKPATHS += -L$(HB_LIB_COMPILE)
LINKLIBS += $(foreach lib, $(LIBS), $(lib)$(LIB_EXT))
endif

# If LIBS specifies the rdd library, add all DB drivers.
ifeq ($(findstring rdd,$(LIBS)),rdd)
ifeq ($(HB_LIB_COMPILE),)
LINKLIBS += $(foreach drv, $(HB_DB_DRIVERS), $(TOP)$(ROOT)/source/rdd/$(drv)/$(ARCH)/$(drv)$(LIB_EXT))
else
LINKPATHS += -L$(HB_LIB_COMPILE)
LINKLIBS += $(foreach drv, $(HB_DB_DRIVERS), $(drv)$(LIB_EXT))
endif
endif

# Add the specified GT driver library
ifeq ($(findstring rtl,$(LIBS)),rtl)
LINKLIBS += $(TOP)$(ROOT)source/rtl/$(HB_GT_LIB)/$(ARCH)/$(HB_GT_LIB)$(LIB_EXT)
endif

# HB_SCREEN_LIB: empty, or one of ncurses, slang
# HB_SCREEN_LIB=ncurses
# HB_SCREEN_LIB=slang

ifneq ($(HB_SCREEN_LIB),)
LINKLIBS += $(HB_SCREEN_LIB)
endif

# Add the optional user path(s)
ifneq ($(LNK_USR_PATH),)
LINKPATHS += $(foreach path, $(LNK_USR_PATH), -L$(path))
endif

# Add the optional user libarary (or libraries)
ifneq ($(LNK_USR_LIB),)
LINKLIBS += $(foreach lib, $(LNK_USR_LIB), $(lib)$(LIB_EXT))
endif

LDFLAGS = $(LINKPATHS)

AR = tlib
ARFLAGS =
AROBJS = $(foreach file, $^, -+$(file))
AR_RULE = $(AR) $(ARFLAGS) $@ $(AROBJS),,

include $(TOP)$(ROOT)config/rules.cf
