# Zinc Application Framework - ZAF.MAK
# COPYRIGHT (C) 1990-1999.  All Rights Reserved.
# Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#############################################################################
#
# "zaf.mak" is the second in a series of four make files used by Zinc's
# make utility "zmake."
#
# The four files used to build ZAF projects are:
# 1. zmake.mak - User supplied make file (see example below)
# 2. zaf.mak - The main ZAF make included by the user make file
# 3. opts???.mak  - Compiler options unique to each compiler
# 4. zaf???.mak  - rule definitions unique to each compiler
#
# Your main make file should take the following form (example only):
#
# --- zake.mak --------------------------------------------------------------
# # Define macros used by main make file
#
# # These macros should be defined by environment variables.
# ZAF_ROOT = c:\zaf500
# ZINC_COMPILER = borland       (options: borland, microsoft, watcom)
#
# # Options common to all targets
# DEBUG = off
# SOURCE_FILES = myapp1.cpp myapp2.cpp
#
# # 16 bit windows.
# TARGET = myapp.exe
# TARGET_TYPE = exe             (options: exe, exedll, lib, libdll, dll)
# PLATFORM = win16              (options: win32, win16)
# DEFINITION_FILE = myapp.def
# RESOURCE_FILE = bitmaps.rc
# !include <zaf.mak>            (generates rules for this target)
#
# # 32 bit windows.
# TARGET = myapp32.exe
# TARGET_TYPE = exe
# PLATFORM = win32
# DEFINITION_FILE =
# RESOURCE_FILE = bitmaps.rc
# !include <zaf.mak>
#
# # 32 bit windows linked to dll.
# TARGET = myapp32d.exe
# TARGET_TYPE = exedll
# PLATFORM = win32
# DEFINITION_FILE =
# RESOURCE_FILE = bitmaps.rc
# !include <zaf.mak>
#
# ---------------------------------------------------------------------------
#
# Macro options and descriptions:
#
# ZINC_COMPILER   - Compiler and tools used to build the target(s)
#      options:   BORLAND
#                 MICROSOFT
#                 WATCOM
#
# ZAF_ROOT        - Root directory of the ZAF installation
#
# PLATFORM        - Target platform supported by this make file
#      options:   WIN32     - 32 bit windows
#                 WIN16     - 16 bit windows
#
# TARGET_TYPE     - The type target to be built
#      options:   EXE       - Executable file statically linked with ZAF
#                 EXEDLL    - Executable file dynamically linked with ZAF
#                 LIB       - Library file
#                 LIBDLL    - Library that calls functions in a ZAF DLL
#                 DLL       - Dynamically linked library file
#
# TARGET          - Name of the target file
#
# SOURCE_FILES    - Source files needed to build the target
#
# IMPORT_LIBRARY (DLLs only)
#                 - Name of import library used with DLL
#
# ADD_OBJECT_FILES (optional)
#                 - Additional object files, if any
#
# ADD_LIBRARIES (optional)
#                 - Additional libraries, if any
#
# DEFINITION_FILE (optional)
#                 - Windows definition file, if any
#
# RESOURCE_FILE (optional)
#                 - Windows Resource file, if any
#
# DEBUG (optional)
#                 - Build with debug information
#      options:   off       - No debug information (default)
#                 on        - Debug information included
#
#############################################################################


#
# Make sure all of the necessary macros are defined.
#
!ifndef ZINC_COMPILER
!error "ZINC_COMPILER" not defined
!elifndef ZAF_ROOT
!error "ZAF_ROOT" not defined
!elifndef TARGET
!error "TARGET" not defined
!elifndef TARGET_TYPE
!error "TARGET_TYPE" not defined
!elifndef PLATFORM
!error "PLATFORM" not defined
!elifndef SOURCE_FILES
!error "SOURCE_FILES" not defined
!endif

#
# Make sure optional macros are defined
#
!ifndef ADD_LIBRARIES
ADD_LIBRARIES=
!endif
!ifndef ADD_OBJECT_FILES
ADD_OBJECT_FILES=
!endif
!ifndef DEFINITION_FILE
DEFINITION_FILE=
!endif
!ifndef RESOURCE_FILE
RESOURCE_FILE=
!endif

#
# Include the compiler options.
#
!ifndef INCLUDE_OPTIONS
INCLUDE_OPTIONS=
!if "$(ZINC_COMPILER)" == "BORLAND" || "$(ZINC_COMPILER)" == "BUILDER"
!include <optsbor.mak>
!elif "$(ZINC_COMPILER)" == "MICROSOFT"
ZINC_COMPILER=microsft
!include <optsmsc.mak>
!elif "$(ZINC_COMPILER)" == "WATCOM"
!include <optswat.mak>
!elif "$(ZINC_COMPILER)" == "SYMANTEC"
!include <optssym.mak>
!elif "$(ZINC_COMPILER)" == "GNU"
!include <optsgnu.mak>
!elif "$(ZINC_COMPILER)" == "DIAB"
!include <optsdiab.mak>
!elif "$(ZINC_COMPILER)" == "CADUL"
!include <optscad.mak>
!else
!error Invalid Compiler "$(ZINC_COMPILER)"
!endif
!endif

#
# Define the debug macros.
#
!if $(DEBUG) == on
DEBUG_COMPILE_OPTIONS=$(DEBUG_COMPILE_OPTIONS_ON)
DEBUG_LINK_OPTIONS=$(DEBUG_LINK_OPTIONS_ON)
DEBUG_LIBRARY_OPTIONS=$(DEBUG_LIBRARY_OPTIONS_ON)
!else
DEBUG_COMPILE_OPTIONS=$(DEBUG_COMPILE_OPTIONS_OFF)
DEBUG_LINK_OPTIONS=$(DEBUG_LINK_OPTIONS_OFF)
DEBUG_LIBRARY_OPTIONS=$(DEBUG_LIBRARY_OPTIONS_OFF)
!endif

#
# Define the target macros.
#
!if "$(PLATFORM)" == "TEXT"

#
# Real Mode Text macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.obt
COMPILER=$(TEXT_COMPILER)
COMPILE_OPTIONS=$(TEXT_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LINKER=$(TEXT_LINKER)
LINK_OPTIONS=$(TEXT_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(TEXT_LIBRARIAN)
LIBRARY_OPTIONS=$(TEXT_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(TEXT_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(TEXT_RESOURCE_OPTIONS)
OBJECT_FILES=$(TEXT_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(TEXT_LIBRARIES) $(ADD_LIBRARIES)

#
# Invalid target type
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "DOS16" || "$(PLATFORM)" == "DOS16B"

#
# DOS 16 bit with Pharlap or Blinker macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.o16
COMPILER=$(D16_COMPILER)
COMPILE_OPTIONS=$(D16_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LIBRARIAN=$(D16_LIBRARIAN)
LIBRARY_OPTIONS=$(D16_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(D16_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(D16_RESOURCE_OPTIONS)

!if "$(PLATFORM)" == "DOS16"

OBJECT_FILES=$(D16_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(D16_LIBRARIES)
LINKER=$(D16_LINKER)
LINK_OPTIONS=$(D16_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)

!else

OBJECT_FILES=$(D16B_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(D16B_LIBRARIES)
LINKER=$(D16B_LINKER)
LINK_OPTIONS=$(D16B_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)

!if "$(DEFINITION_FILE)" == "$(D16_DEFINITION_FILE)" || "$(DEFINITION_FILE)" == ""
DEFINITION_FILE=nul
!endif

!endif

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "DOS32"

#
# DOS 32 bit macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.o32
COMPILER=$(D32_COMPILER)
COMPILE_OPTIONS=$(D32_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LINKER=$(D32_LINKER)
LINK_OPTIONS=$(D32_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(D32_LIBRARIAN)
LIBRARY_OPTIONS=$(D32_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(D32_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(D32_RESOURCE_OPTIONS)
OBJECT_FILES=$(D32_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(D32_LIBRARIES)

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "WIN16"

#
# Windows 16 bit macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.ob1
COMPILER=$(W16_COMPILER)
COMPILE_OPTIONS=$(W16_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LINKER=$(W16_LINKER)
LINK_OPTIONS=$(W16_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(W16_LIBRARIAN)
LIBRARY_OPTIONS=$(W16_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(W16_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(W16_RESOURCE_OPTIONS)
OBJECT_FILES=$(W16_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(W16_LIBRARIES)

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "WIN32"
#
# Windows 32 bit macros (statically linked executable or library)
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.obw
COMPILER=$(W32_COMPILER)
COMPILE_OPTIONS=$(W32_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILE_OPTIONS)
LINKER=$(W32_LINKER)
LINK_OPTIONS=$(W32_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(W32_LIBRARIAN)
LIBRARY_OPTIONS=$(W32_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(W32_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(W32_RESOURCE_OPTIONS)
OBJECT_FILES=$(W32_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(W32_LIBRARIES)

#
# Windows 32 bit macros (dynamically linked executable or library)
#
!elif "$(TARGET_TYPE)" == "EXEDLL" || "$(TARGET_TYPE)" == "LIBDLL"
OBJECT_FILE_EXTENSION=.obi
COMPILER=$(W32_COMPILER)
COMPILE_OPTIONS=$(W32_DLL_IMPORT_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILE_OPTIONS)
LINKER=$(W32_LINKER)
LINK_OPTIONS=$(W32_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(W32_LIBRARIAN)
LIBRARY_OPTIONS=$(W32_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(W32_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(W32_RESOURCE_OPTIONS)
OBJECT_FILES=$(W32_DLL_IMPORT_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(W32_DLL_IMPORT_LIBRARIES)

#
# Windows 32 bit DLL macros.
#
!elif "$(TARGET_TYPE)" == "DLL"
OBJECT_FILE_EXTENSION=.obx
COMPILER=$(W32_COMPILER)
COMPILE_OPTIONS=$(W32_DLL_EXPORT_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILE_OPTIONS)
LINKER=$(W32_LINKER)
LINK_OPTIONS=$(W32_DLL_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(W32_LIBRARIAN)
LIBRARY_OPTIONS=$(W32_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(W32_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(W32_RESOURCE_OPTIONS)
OBJECT_FILES=$(W32_DLL_EXPORT_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(W32_DLL_EXPORT_LIBRARIES)

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "VXWORKS"

#
# VxWorks macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=.o
COMPILER=$(GNU_COMPILER)
COMPILE_OPTIONS=$(GNU_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LINKER=$(GNU_LINKER)
LINK_OPTIONS=$(GNU_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(GNU_LIBRARIAN)
LIBRARY_OPTIONS=$(GNU_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(GNU_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(GNU_RESOURCE_OPTIONS)
OBJECT_FILES=$(GNU_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(GNU_LIBRARIES)

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

!elif "$(PLATFORM)" == "PSOS"

#
# pSOS macros.
#
!if "$(TARGET_TYPE)" == "EXE" || "$(TARGET_TYPE)" == "LIB"
OBJECT_FILE_EXTENSION=$(PSOS_OBJ_FILE_EXT)
COMPILER=$(PSOS_COMPILER)
COMPILE_OPTIONS=$(PSOS_COMPILE_OPTIONS) $(ADD_COMPILE_OPTS) $(DEBUG_COMPILER_OPTIONS)
LINKER=$(PSOS_LINKER)
LINK_OPTIONS=$(PSOS_LINK_OPTIONS) $(DEBUG_LINK_OPTIONS)
LIBRARIAN=$(PSOS_LIBRARIAN)
LIBRARY_OPTIONS=$(PSOS_LIBRARY_OPTIONS) $(DEBUG_LIBRARY_OPTIONS)
RESOURCE_COMPILER=$(PSOS_RESOURCE_COMPILER)
RESOURCE_COMPILE_OPTIONS=$(PSOS_RESOURCE_OPTIONS)
OBJECT_FILES=$(PSOS_OBJECT_FILES) $(ADD_OBJECT_FILES)
LIBRARIES=$(ADD_LIBRARIES) $(PSOS_LIBRARIES)

#
# Invalid target type.
#
!else
!error Invalid target type: $(TARGET_TYPE)
!endif

#
# Invalid platform
#
!else
!error Invalid platform: $(PLATFORM)
!endif

#
# Define the dependency macro.
#
DEPENDENCY_FILES=$(SOURCE_FILES:.cpp=$(OBJECT_FILE_EXTENSION)) $(ADD_DEPENDENCIES)
DEPENDENCY_FILES=$(DEPENDENCY_FILES:.c=$(OBJECT_FILE_EXTENSION))

#
# Define the object files macro.
#
OBJECT_FILES_LINK=$(OBJECT_FILES) $(SOURCE_FILES:.cpp=$(OBJECT_FILE_EXTENSION))
OBJECT_FILES_LINK=$(OBJECT_FILES_LINK:.c=$(OBJECT_FILE_EXTENSION))
OBJECT_FILES_LIB=$(SOURCE_FILES:.cpp=$(OBJECT_FILE_EXTENSION))
OBJECT_FILES_LIB=$(OBJECT_FILES_LIB:.c=$(OBJECT_FILE_EXTENSION))

#
# Define the res file macro.
#
!if "$(PLATFORM)" == "WIN16"
RES_FILE=$(RESOURCE_FILE:.rc=.r16)
!else
RES_FILE=$(RESOURCE_FILE:.rc=.res)
!endif

#
# Include the rule definitions.
#
!if "$(ZINC_COMPILER)" == "BORLAND" || "$(ZINC_COMPILER)" == "BUILDER" && \
("$(PLATFORM)" == "TEXT" || \
"$(PLATFORM)" == "DOS16" || "$(PLATFORM)" == "DOS16B" || \
"$(PLATFORM)" == "WIN16" || "$(PLATFORM)" == "WIN32" || \
"$(PLATFORM)" == "WIN32DLL")
!include <zafbor.mak>
!elif "$(ZINC_COMPILER)" == "MICROSFT" && ("$(PLATFORM)" == "WIN16" || \ 
"$(PLATFORM)" == "WIN32" || "$(PLATFORM)" == "WIN32DLL")
!include <zafmsc.mak>
!elif "$(ZINC_COMPILER)" == "WATCOM" && ("$(PLATFORM)" == "TEXT" || \ 
"$(PLATFORM)" == "DOS32" || "$(PLATFORM)" == "DOS16B" || \
"$(PLATFORM)" == "WIN16" || "$(PLATFORM)" == "WIN32" || \
"$(PLATFORM)" == "WIN32DLL")
!include <zafwat.mak>
!elif "$(ZINC_COMPILER)" == "SYMANTEC" && ("$(PLATFORM)" == "TEXT" || \
"$(PLATFORM)" == "DOS16" || "$(PLATFORM)" == "DOS16B" || \
"$(PLATFORM)" == "WIN16" || "$(PLATFORM)" == "WIN32" || \
"$(PLATFORM)" == "WIN32DLL")
!include <zafsym.mak>
!elif "$(ZINC_COMPILER)" == "GNU" && "$(PLATFORM)" == "VXWORKS"
!include <zafgnu.mak>
!elif "$(ZINC_COMPILER)" == "DIAB" && "$(PLATFORM)" == "PSOS"
!include <zafdiab.mak>
!elif "$(ZINC_COMPILER)" == "CADUL" && "$(PLATFORM)" == "PSOS"
!include <zafcad.mak>
!endif
