#
# $Id$
#

ifndef MK

all : first

HB_GT_LIST=\
	gtcgi \
	gtpca \
	gtstd \
	gtdos \

#	gtcrs \
#	gtsln \

ifeq ($(HB_GTALLEG),yes)
   HB_GT_LIST += gtalleg
endif

# verify if GT drivers exist
#HB_GT_LIBS := $(foreach gt, $(HB_GT_LIST), $(if $(wildcard $(TOP)$(ROOT)source/rtl/$(gt)),$(gt),))
HB_GT_LIBS := $(HB_GT_LIST)

ifeq ($(HB_GT_LIB),)
   HB_GT_LIB = gtdos
endif

ifeq ($(SHLVL),) # COMMAND.COM

# There is a conflict with the use of '\' and '/' characters
# The MAKE requires '/' in filenames (ARCH_DIR) however some compilers
# and some DOS commands require '\' (ARCH_DOS)
ARCH_DIR = $(subst \,/,$(HB_ARCH))
ARCH_DOS = $(subst /,\,$(HB_ARCH))
DIRSEP = $(subst /,\,\)

MK := $(subst \,/,$(subst \~,~,$(MAKE)))

ifeq ($(COMSPEC),) #location of command.com
   COMSPEC := command.com
else
   ifeq ($(HB_COMPILER),bcc16)
      #Use standard dos path, which is already set up.
   else
      ifeq ($(HB_COMPILER),rsx32)
         #Use standard dos path, which is already set up.
      else
         ifneq ($(findstring watcom,$(HB_COMPILER)),)
            #Use standard dos path, which is already set up.
         else
            ifeq ($(HB_COMPILER),djgpp)
               #Use standard dos path, which is already set up.
            else
               ifeq ($(HB_COMPILER),emx)
                  #Use standard dos path, which is already set up.
               else
                  COMSPEC := $(subst \,/,$(COMSPEC))
               endif
            endif
         endif
      endif
   endif
endif

RM = del
RD = rmdir
CP = $(COMSPEC) /Ccopy
MV = move
MD = md

#this will be used only under DJGPP
RANLIB = ranlib

dirbase::
	-@$(COMSPEC) /Cfor %d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %d\nul $(MD) %d

clean::
	-@$(COMSPEC) /Cfor %f in ($(ARCH_DOS)\*.* *.bak *.obj *.o *.tds) do $(RM) %f
	-@$(COMSPEC) /Cfor %d in ($(ARCH_DOS) $(HB_ARCHITECTURE)) do if exist %d\nul $(RD) %d

else  # bash

ARCH_DIR = $(HB_ARCH)
MK = $(MAKE)

RM = rm -f
RD = rm -f -r
CP = cp -f
MV = mv -f
MD = mkdir

#this will be used only under MINGW
RANLIB = ranlib


dirbase::
	@[ -d $(HB_ARCHITECTURE) ] || $(MD) $(HB_ARCHITECTURE); \
	 [ -d $(ARCH_DIR) ] || $(MD) $(ARCH_DIR)

clean::
	-$(RD) $(HB_ARCH)

endif
endif
