#
# $Id$
#
# The Harbour Project
# GNU MAKE file for xHarbour.com POCC compiler

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

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

CC = xcc.exe
CC_IN = -c
CC_OUT = -Fo
CPPFLAGS = -I. -I$(TOP) -I$(TOP)$(ROOT)
# disabled - it produces bad code
#CPPFLAGS += -Ot

# For Pocket PC and ARM processors (including XScale)
#CPPFLAGS += /Tarm-coff

ifneq ($(HB_INC_COMPILE),)
CPPFLAGS += -I$(HB_INC_COMPILE)
endif

CFLAGS = 

LD = xlink.exe
LD_OUT = -OUT:

# Add all libraries specified in CONTRIBS and LIBS.
ifeq ($(HB_LIB_COMPILE),)
LINKPATHS += $(foreach lib, $(CONTRIBS), -LIBPATH:$(TOP)$(ROOT)contrib/$(lib)/$(HB_ARCH))
LINKPATHS += $(foreach lib, $(LIBS), -LIBPATH:$(TOP)$(ROOT)source/$(lib)/$(HB_ARCH))
else
LINKPATHS += -LIBPATH:$(HB_LIB_COMPILE)
endif
LINKLIBS += $(foreach lib, $(CONTRIBS), $(subst lib,,$(lib))$(LIB_EXT))
LINKLIBS += $(foreach lib, $(LIBS), $(lib)$(LIB_EXT))

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

# Add the specified GT driver library
ifeq ($(findstring rtl,$(LIBS)),rtl)
ifeq ($(HB_LIB_COMPILE),)
LINKPATHS += $(foreach gt, $(HB_GT_LIBS), -LIBPATH:$(TOP)$(ROOT)source/rtl/$(gt)/$(HB_ARCH))
endif
LINKLIBS += $(foreach gt, $(HB_GT_LIBS), $(gt)$(LIB_EXT))
endif

LDFLAGS = $(LINKPATHS) kernel32.lib user32.lib \
          winspool.lib ole32.lib oleaut32.lib uuid.lib \
          comctl32.lib mapi32.lib advapi32.lib \
          gdi32.lib mpr.lib wsock32.lib

ifeq ($(HB_GT_DEFAULT),gtgui)
LDFLAGS += /SUBSYSTEM:WINDOWS
else
ifeq ($(HB_GT_LIB),gtgui)
LDFLAGS += /SUBSYSTEM:WINDOWS
endif
endif

# mpr wsock32 ws2_32 mapi32

AR = xlib.exe
ARFLAGS = $(A_USR)
AR_RULE = $(AR) $(ARFLAGS) /out:$@ $(^F)

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