# Test Makefile for nmake
#
# SYNOPSIS:
#
#   make [all]  - makes everything.
#   make TARGET - makes the given target.
#   make test   - makes everything and run.
#   make clean  - removes all files generated by make.

#
# Optimize
#
#OPTIMIZE += /O2

#
# Flags passed to the C++ compiler.
CCFLAGS =$(CCFLAGS) /nologo $(OPTIMIZE)
CCFLAGS =$(CCFLAGS) $(DEFS) $(STDFLAG)

!ifdef OUTPUTXML
CCFLAGS =$(CCFLAGS) -DOUTPUTXML
!endif

#
# Command
#
RM = del

#
# include
#
!include <CommonMakefile.in>


OBJS   = $(TARGETS:_tests=_tests.o)
SRCS   = $(TARGETS:_tests=_tests.c)
RUNNER = $(TARGETS:iutest=run_iutest)

# House-keeping build targets.

default: $(TARGETS)

all : clean default test

clean :
	$(RM) *.exe *.obj
!ifdef OUTPUTXML
	$(RM) *.xml
!endif

run: test
test: $(RUNNER)

$(RUNNER) : $(@:run_=)
	@echo $@
!ifdef OUTPUTXML
	$(@:run_=) $(RUN_OPTION) --iutest_output=xml:$<.xml
!else
	$(@:run_=) $(RUN_OPTION)
!endif

# Builds a sample test.  

$(TARGETS) : $(SRCS) $(IUTEST_HEADERS) Makefile
	$(CC) $(IUTEST_INCLUDE) $(CCFLAGS) /Fe$@ $@.c
