!ifdef INCLUDE
INCLUDE_OPTION=-I$(INCLUDE)
!else
INCLUDE_OPTION=-I$(ZAF_ROOT)\include
!endif

!ifdef LIB
LIB_OPTION=-L$(LIB)
!endif

!ifndef IMPLICIT_RULES_DEFINED
IMPLICIT_RULES_DEFINED=
#
# Impicit rules for building object files.
#
.cpp.obt:
    $(TEXT_COMPILER) -c -o$*.obt @<<
$(TEXT_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.c.o16:
	$(D16_COMPILER) -c -o$*.o16 @<<
$(D16_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.o16:
	$(D16_COMPILER) -c -o$*.o16 @<<
$(D16_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.o32:
	$(D32_COMPILER) -c -o$*.o32 @<<
$(D32_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.ob1:
	$(W16_COMPILER) -c -o$*.ob1 @<<
$(W16_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.obw:
	$(W32_COMPILER) -c -o$*.obw @<<
$(W32_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.obx:
	$(W32_COMPILER) -c -o$*.obx @<<
$(W32_DLL_EXPORT_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.cpp.obi:
	$(W32_COMPILER) -c -o$*.obi @<<
$(W32_DLL_IMPORT_COMPILE_OPTIONS) $(DEBUG_COMPILE_OPTIONS) $(INCLUDE_OPTION) $<
<<

.rc.r16:
	$(W16_RESOURCE_COMPILER) $(W16_RESOURCE_OPTIONS) -r -fo$*.r16 $<

.rc.res:
	$(W32_RESOURCE_COMPILER) $(W32_RESOURCE_OPTIONS) -r $<
!endif


OBJECT_FILES_LIB=$(OBJECT_FILES_LIB: =+)

#
# Explicit rule for building executables.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "EXEDLL"
$(TARGET): $(DEPENDENCY_FILES) $(RES_FILE)
	$(LINKER) $(LINK_OPTIONS) @<<
$(LIB_OPTION) $(OBJECT_FILES_LINK)
$*, , $(LIBRARIES), $(DEFINITION_FILE), $(RES_FILE)
<<
!if "$(PLATFORM)" == "DOS16"
	$(D16_BIND) $(D16_PHARLAP_RTL)\$(D16_LOAD) $* -dll $(D16_PHARLAP_RTL)\moucalls $(D16_PHARLAP_RTL)\int33 $(D16_PHARLAP_RTL)\doscalls
!endif
!endif

#
# Explicit rule for building DLL's
#
!if "$(TARGET_TYPE)" == "DLL"
$(TARGET): $(DEPENDENCY_FILES) $(RES_FILE)
	$(LINKER) @<<
$(LIB_OPTION) $(LINK_OPTIONS) $(OBJECT_FILES_LINK)
$*, , $(LIBRARIES), $(DEFINITION_FILE), $(RES_FILE)
<<
	-@del $(IMPORT_LIBRARY)
	implib $(IMPORT_LIBRARY) $(TARGET)
!endif

#
# Explicit rule for building libraries.
#
!if "$(TARGET_TYPE)" == "LIB" || "$(TARGET_TYPE)" == "LIBDLL"
$(TARGET): $(DEPENDENCY_FILES)
	-@del $(TARGET)
	$(LIBRARIAN) $(LIBRARY_OPTIONS) $(TARGET) @<<
+$(OBJECT_FILES_LIB)
<<
!endif

