#
# $Id$
#

ifneq ($(HB_ARCHITECTURE),)
ifneq ($(HB_COMPILER),)

include $(TOP)$(ROOT)config/global.cf
include $(TOP)$(ROOT)config/c.cf
include $(TOP)$(ROOT)config/prg.cf

EXE_NAME=

ifneq ($(C_MAIN),)
ifeq ($(EXE_NAME),)
EXE_NAME = $(C_MAIN:.c=$(EXE_EXT))
endif
endif

ifneq ($(PRG_MAIN),)
ifeq ($(EXE_NAME),)
EXE_NAME = $(PRG_MAIN:.prg=$(EXE_EXT))
endif
endif

_EXE_ARCH = $(notdir $(ARCH_DIR))
ifeq ($(_EXE_ARCH),)
# ARCH_DIR ends with a slash
EXE_ARCH = $(ARCH_DIR)$(EXE_NAME)
else
EXE_ARCH = $(ARCH_DIR)/$(EXE_NAME)
endif

ALL_OBJS = $(ALL_C_OBJS) $(ALL_PRG_OBJS)

first:: dirbase descend

descend :
	@$(MK) -C $(ARCH_DIR) -f $(GRANDP)Makefile 'TOP=$(GRANDP)' $(EXE_NAME)

$(EXE_NAME) : $(ALL_OBJS)
	$(LD_RULE)


INSTALL_OBJS = $(EXE_ARCH)
INSTALL_DIR = $(HB_BIN_INSTALL)

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

endif
endif
