#
# $Id$
#

all : first

HB_GT_LIST=\
	gtcgi \
	gtpca \
	gtstd \
	gtwin \
	gtwvt \
	gtgui \

#	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),))

ifeq ($(HB_GT_LIB),)
   HB_GT_LIB = gtwin
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
	ifeq ($(OS),Windows_NT)
		COMSPEC := cmd.exe
	else
		COMSPEC := command.com
	endif
endif

ifeq ($(findstring cmd.exe,$(COMSPEC)),cmd.exe)
  CMD_EXE := yes
else
  CMD_EXE := no
endif

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

ifeq ($(CMD_EXE),yes)

RM = del /q /f
RD = rmdir /q /s

dirbase::
	-@$(COMSPEC) /c \
	'for %d in ($(HB_ARCHITECTURE) $(ARCH_DOS)) do if not exist %d\. $(MD) %d'

clean::
	-@$(COMSPEC) /c \
	'if exist $(ARCH_DOS) $(RD) $(ARCH_DOS)'

else # command.com

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

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

endif

else  # bash

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

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

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

clean::
	-$(RD) $(ARCH_DIR)

endif
