#  CONFIG.linux-x86-borland.linux-x86-borland
#
# $Revision-Id$
#
# Definitions for linux-x86-borland host - linux-x86-borland target builds
# Sites may override these definitions in CONFIG_SITE.linux-x86-borland.linux-x86-borland
#-------------------------------------------------------

# Include common gnu compiler definitions
include $(CONFIG)/CONFIG.gnuCommon
SHRLIB_CFLAGS =
SHRLIB_LDFLAGS =
LOADABLE_SHRLIB_LDFLAGS =
GPROF=NO
PROFILE=NO

GNU_DIR = /usr

KYLIX=1

BORLAND_INC_STLPORT = $(BORLAND)/include/stlport
BORLAND_INC = $(BORLAND)/include
BORLAND_LIB = $(BORLAND)/lib
BORLAND_BIN = $(BORLAND)/bin

WINLINK = $(BORLAND_BIN)/ilink -q
#
# Configure Borland C compiler
# -q suppress compiler identification banner
# -a8 quad word alignment
#CCLINKOPT = -q -a8 -I/usr/include
CCLINKOPT = -q -a8
CC = $(BORLAND_BIN)/bc++ $(CCLINKOPT)
LD = $(BORLAND_BIN)/bc++ -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-dup
# -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)/bcpp

# Configure OS vendor C++ compiler
#
CCC = $(BORLAND_BIN)/bc++ $(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 =

# -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-
#Linux_DLLFLAGS = $(LINK_OPT_FLAGS_$(HOST_OPT)) $(TARGET_LDFLAGS) $(LIB_LDFLAGS)
OPT_LDFLAGS =

ARCH_DEP_CFLAGS=

OS_CLASS=Linux


OBJ=.o

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

#	Operating system flags 
OP_SYS_CFLAGS =

#
# Borland specific include files
#
OP_SYS_INCLUDES = -I/usr/include
#

#-------------------------------------------------------
# Prod: DEPLIBS, LDFLAGS, and LDLIBS definitions

PROD_DEPLIBS=	$(foreach lib,$(PROD_LIBS) $(USR_LIBS), \
		$(firstword $(wildcard $(addsuffix /$(LIB_PREFIX)$(lib).so, \
    		$($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
		$(wildcard $(addsuffix /$(LIB_PREFIX)$(lib).a, \
    		$($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
		$(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_EXT), \
    		$(firstword $($(lib)_DIR) $(INSTALL_LIB)))))

SHRLIB_DEPLIBS=	$(foreach lib,$(LIB_LIBS) $(USR_LIBS), \
		$(firstword $(wildcard $(addsuffix /$(LIB_PREFIX)$(lib).so, \
    		$($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
		$(wildcard $(addsuffix /$(LIB_PREFIX)$(lib).a, \
    		$($(lib)_DIR) $(SHRLIB_SEARCH_DIRS))) \
		$(addsuffix /$(LIB_PREFIX)$(lib)$(LIB_EXT), \
    		$(firstword $($(lib)_DIR) $(INSTALL_LIB)))))

PROD_SYS_DEPLIBS= 	$(foreach lib,$(PROD_SYS_LIBS), \
			$(firstword $(wildcard \
			/lib/$(LIB_PREFIX)$(lib).so \
			/lib/$(LIB_PREFIX)$(lib).a \
			/usr/lib/$(LIB_PREFIX)$(lib).so \
			/usr/lib/$(LIB_PREFIX)$(lib).a) \
			$(lib)))

PROD_LDLIBS = 	$(addprefix lib, $($*_LDLIBS)) \
		$(notdir $(PROD_DEPLIBS)) \
		$(notdir $(PROD_SYS_DEPLIBS)) \
		$(addprefix lib, $($*_SYS_LIBS) $(USR_SYS_LIBS))

SHRLIB_LDLIBS = $(addprefix lib, $($*_LDLIBS)) \
		$(notdir $(SHRLIB_DEPLIBS)) \
		$(addprefix lib, $($*_SYS_LIBS) $(LIB_SYS_LIBS) $(USR_SYS_LIBS)) $(LDLIBS)

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

empty:=
space:= $(empty) $(empty)
PROD_DEPLIB_DIRS =   $(dir $($*_DEPLIBS)) $(dir $(PROD_DEPLIBS))
SHRLIB_DEPLIB_DIRS = $(dir $($*_DEPLIBS)) $(dir $(SHRLIB_DEPLIBS))

PRODDIR_LDFLAGS =   -L$(subst $(space),:,$(sort $(PROD_DEPLIB_DIRS) $(BORLAND_LIB)))
SHRLIBDIR_LDFLAGS = -L$(subst $(space),:,$(sort $(SHRLIB_DEPLIB_DIRS) $(BORLAND_LIB)))

# -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 -x -w
LINKLIBS=rtl.a visualclx.a rtle.a libborcrtl.a libborstl.a libborunwind.a

LINK.cpp = $(WINLINK) $(STATIC_LDFLAGS) $(PRODDIR_LDFLAGS) $(LDFLAGS) -Tpe -w-dup
LINK.cpp += $(PROD_LDFLAGS) borinit.o /usr/lib/crt1.o $(PROD_LD_OBJS)
LINK.cpp += , $@ ,,$(LINKLIBS) $(PROD_LDLIBS)

LINK.shrlib = $(WINLINK) $(STATIC_LDFLAGS) $(SHRLIBDIR_LDFLAGS) $(LDFLAGS) -Tpd -Gi
LINK.shrlib+= $(TARGET_LIB_LDFLAGS) borinitso.o $(LIBRARY_LD_OBJS) 
LINK.shrlib+= , $@ ,,$(LINKLIBS) $(SHRLIB_LDLIBS)

