#
# Makefile for running on test programs.
#
###########################################################################

###########################################################################
# Add list of Source Files here

SRC=t_sb_arc.cpp  t_sb_catalogcrossref.cpp t_sb_catalogdir.cpp \
    t_sb_catalogspatialdom.cpp t_sb_datadictdefn.cpp t_sb_datadictdom.cpp \
    t_sb_datadictschema.cpp t_sb_extspatialref.cpp t_sb_ident.cpp \
    t_sb_intspatialref.cpp t_sb_line.cpp t_sb_point.cpp t_sb_polygon.cpp \
    t_sb_registration.cpp  t_sb_security.cpp t_sb_transferstats.cpp \
    t_sb_rasterdefn.cpp 
 

###########################################################################
# Add name of library to link to.  Include absolute or relative path name

LIBRARY=t_sb_output.obj ..\builder\Release\builder.lib \
         ..\container\Release\container.lib \
         ..\io\Release\io.lib

###########################################################################
#Add include path(s) for header files used in test prgms.

INC=..

###########################################################################
#List of header files used with the library and included in the test prgms

LIB_HDRS=t_sb_output.h

###########################################################################
# Define the type of programs the test programs are.

TYPE=Win32_Console_No_MFC

# List of possible tests
# Win32_Console_No_MFC  - Console prgm with _no_ MFC support
# Win32_Console_MFC     - Console prgm with MFC support - static libs
# Win32_Console_MFC_DLL - Console prgm with MFC support - shared libs
# Win32_Window_No_MFC   - GUI prgm with no MFC support.
# Win32_Window_MFC      - GUI prgm with MFC suport. - static libs
# Win32_Window_MFC_DLL  - GUI prgm with MFC suport. - shared libs
###########################################################################


#
# End user defined section
###########################################################################

# Error Checking

!IF "$(SRC)" == ""
!MESSAGE "Please put a list of the source files in the Makefile"
!ERROR "No Source files."
!ENDIF

!IF "$(LIBRARY)" == "" 
!MESSAGE "Please put the name of the library you wish the programs 
!MESSAGE "linked to in the Makefile"
!ERROR "No library was specified"
!ENDIF

#
# Pre set for Visual C++
#     Set macros for use with Visual C++
###########################################################################
CC=cl
LD=cl 
LDOPT=/link /nologo /machine:I386 
CFLAG=/nologo /W3 /GX

#
#  Default platform is always Win32.
#    Check to see if the DEBUG makefile macro is defines, if so
#    setup debuging in the executables.
###########################################################################
!IFDEF DEBUG
Win32=/D"WIN32" /D"_DEBUG"
!ELSE
Win32=/D"WIN32" /D"NDEBUG"
!ENDIF


#
#  Program display options:  Console based app, or window based app.
#
###########################################################################
Console=/D"_CONSOLE" /D"_MBCS"
LinkConsole=/subsystem:console

Window=/D"_Window"
LinkWindow=/subsystem:windows

#
#  MFC options: no mfc, mfc with static libs, mfc with dynamic libs.
#
###########################################################################
NO_MFC=/ML 
MFC=/MT
MFC_DLL=/MD /D "_AFXDLL"


.SUFFIXES:
.SUFFIXES:.obj .cpp

#
# end predefs.
#
############################################################################

#
#  Based on the value of TYPE macro, set above, set the appropriate
#     options for that program type and place them in the CFLAGS macro.
#
#  Output the configuration option that was set.  
#  If no config options is set default to a configuration as if
#  TYPE=Win32_Console_MFC 
#  Configuration for a Console app with MFC static lib support.
#
############################################################################

!IF "$(TYPE)" == "Win32_Console_No_MFC"
!MESSAGE Using configuration for Console prgm with _no_ MFC support
CFLAGS=$(CFLAG) $(Win32) $(Console) $(NO_MFC)
LDOPTS=$(LDOPT) $(LinkConsole)

!ELSEIF "$(TYPE)" == "Win32_Console_MFC"
!MESSAGE Using configuration for Console prgm with MFC support - static libs
CFLAGS=$(CFLAG) $(Win32) $(Console) $(MFC)
LDOPTS=$(LDOPT) $(LinkConsole)

!ELSEIF "$(TYPE)" == "Win32_Console_MFC_DLL"
!MESSAGE Using configuration for Console prgm with MFC support - shared libs
CFLAGS=$(CFLAG) $(Win32) $(Console) $(MFC_DLL)
LDOPTS=$(LDOPT) $(LinkConsole)


!ELSEIF "$(TYPE)" == "Win32_Window_No_MFC"
!MESSAGE Using configuration for GUI prgm with no MFC support.
CFLAGS=$(CFLAG) $(Win32) $(Window) $(NO_MFC)
LDOPTS=$(LDOPT) $(LinkWindow)


!ELSEIF "$(TYPE)" == "Win32_Window_MFC"
!MESSAGE Using configuration for GUI prgm with MFC suport. - static libs
CFLAGS=$(CFLAG) $(Win32) $(Window) $(MFC)
LDOPTS=$(LDOPT) $(LinkWindow)

!ELSEIF "$(TYPE)" == "Win32_Window_MFC_DLL"
!MESSAGE   Using configuration for GUI prgm with MFC suport. - shared libs
CFLAGS=$(CFLAG) $(Win32) $(Window) $(MFC_DLL)
LDOPTS=$(LDOPT) $(LinkWindow)

!ELSE
!MESSAGE You didn't set the Type of program to use
!MESSAGE Using default configuration.
!MESSAGE      DEFAULT: Console prgm with MFC suport. - static libs
CFLAGS=$(CFLAG) $(Win32) $(Console) $(MFC)
LDOPTS=$(LDOPT) $(LinkConsole)

!ENDIF

#
# End Type configuration
###########################################################################


#
# Begin Makefile Rules
#
###########################################################################
OBJS=$(SRC:.cpp=.obj)
EXES=$(OBJS:.obj=.exe)

# Turn off output from commands and command display.

.SILENT:

# Default target.
#  Executes a recursive make to garentee proper build.
#
all:
        @cmd /c $(MAKE) /C /nologo $(OBJS) $(EXES)
	@echo. 
	@echo Programs up to date.


$(OBJS) : $$(@B).cpp $(LIB_HDRS)
        $(CC) /I$(INC) $(CFLAGS) /c $*.cpp /Fo$@

t_sb_output.obj : t_sb_output.h t_sb_output.cpp
        $(CC) /I$(INC) $(CFLAGS)  /c $*.cpp /Fo$@
	
$(EXES): $$(@B).obj $(LIBRARY)
        $(LD) $*.obj /Fe$@ $(LDOPTS) $(LIBRARY)
	
# dummy target to simplify recursive make.
nmake:

#
# Rebuild all executables, and objects.
#

rebuild:
	@echo.
	@echo To rebuild run: nmake clean
	@echo 	    then run: nmake

#
# Delete all the executalbes and object files.
#
clean:
	del /q /f *.obj *.exe





