#
# Rules	for building an	executable
#
# Inputs:
# ~~~~~~~
# NAME - undecorated name of target
# CFLAGS - extra compiler flags	for building target
# CPPDIR - list	of directories containing source files
# OBJFILES - list of (non-system) object files
# LIBFILES - list of (non-system) libraries
# STATIC - if defined means link exe with static libraries
# PASCAL - if defined means link dll against pascal run-time library
# DEBUG	- if defined means building with debug information
#

!include <$(ACE_ROOT)\include\makeinclude\decorator.bor>
!include <$(ACE_ROOT)\include\makeinclude\outputdir.bor>
!include <$(ACE_ROOT)\include\makeinclude\compiler.bor>

!ifdef NAME
!ifndef TARGET
TARGET = $(BINDIR)\$(NAME).exe
!endif
!ifdef INSTALL_THIS_TARGET
# We use a separate CORE_TARGET to copy the executable to the
# core bin directory. This is so there will be a copy of the
# exe file left in the local directory for the test scripts
# to use.
CORE_TARGET = $(CORE_BINDIR)\$(NAME).exe
!endif
!endif

all: $(TARGET) $(CORE_TARGET)
	@echo Do nothing >NUL

!ifdef TARGET
$(TARGET): $(OBJFILES) $(RESOURCE)
	@$(MAKE_BINDIR)
	$(LD) @&&!
	$(COMMON_LFLAGS) $(EXE_LFLAGS) $(LFLAGS) +
	$(EXE_STARTUP_OBJ) $(OBJFILES),	+
	$(TARGET),, +
	$(COMMON_LIBS) $(LIBFILES),, +
	$(RESOURCE)
!
!ifndef	DEBUG
	@del $(TARGET:.exe=.tds)
!endif
!ifdef CORE_TARGET
$(CORE_TARGET): $(TARGET)
	@copy $(TARGET) $(CORE_TARGET) >NUL
!ifdef DEBUG
	@copy $(TARGET:.exe=.tds) $(CORE_TARGET:.exe=.tds) >NUL
!endif
!endif
!endif


!include <$(ACE_ROOT)\include\makeinclude\clean.bor>

INSTALL_TYPES =	exe

!include <$(ACE_ROOT)\include\makeinclude\install.bor>

!ifdef CPPDIR
.path.cpp = $(CPPDIR)
!endif

!ifdef CDIR
.path.c	= $(CDIR)
!endif

!ifdef RESDIR
.path.rc = $(RESDIR)
!else
.path.rc = .
!endif

.path.obj = $(OBJDIR)

.cpp.obj:
	@$(MAKE_OBJDIR)
	$(CC) $(COMMON_CFLAGS) $(EXE_CFLAGS) $(CFLAGS) -c -n$(@D) $<

.c.obj:
	@$(MAKE_OBJDIR)
	$(CC) $(COMMON_CFLAGS) $(EXE_CFLAGS) $(CFLAGS) -c -n$(@D) $<

.rc.res:
	@$(MAKE_OBJDIR)
	$(RC) -fo$@ $<

.autodepend
