################################################################################
# File:		makefile
#
# Purpose:	Builds the DTL (D Template Library)
#
# Created:	12th March 2004
# Updated:	18th August 2004
#
# Author:	Matthew Wilson
#
################################################################################

DMD	=	dmd
AR	=	lib
LD	=	dmd

SYNSOFT_D_ROOT				=	$(SYNSOFT_ROOT)\D
SYNSOFT_D_PHOBOS_ROOT		=	$(SYNSOFT_ROOT)\D\phobos

SYNSOFT_DTL_ROOT			=	$(SYNSOFT_D_ROOT)\dtl

DINCLUDE					=	-I$(SYNSOFT_D_ROOT) -I$(SYNSOFT_D_PHOBOS_ROOT)

DMD_DEBUG_ARGS				=	-c #-v #-unittest -debug -g -v

DTL_LIB						=	dtl.lib


LD_ARGS						=	/NOLOGO

all:	target

usage:
	-@echo "Select a target: { target | test | clean }"

test:								\
			target					\
									\
			test_enumerator			\
									\
			test_list				\
			test_map				\
			test_queue				\
			test_set				\
			test_stack				\
			test_vector				\
									\
			test_intrange			\
									\
									\
			test_interfaces			\
									\

#			test_ranges				\
			
target:								\
									\
			$(DTL_LIB)				\
									\
			test_enumerator.exe		\
									\
			test_list.exe			\
			test_map.exe			\
			test_queue.exe			\
			test_set.exe			\
			test_stack.exe			\
			test_vector.exe			\
									\
			test_intrange.exe		\
									\
									\
			test_interfaces.exe		\
									\

#			test_ranges.exe			\


clean:
	@-if exist $(DTL_LIB) del /F $(DTL_LIB)
	@-if exist .\*.bak del /F .\*.bak
	@-if exist .\*.exe del /F .\*.exe
	@-if exist .\*.map del /F .\*.map
	@-if exist .\*.obj del /F .\*.obj
	@-if exist .\*.scc del /F .\*.scc
	@-if exist .\algorithms\*.obj del /F .\algorithms\*.obj
	@-if exist .\exceptions\*.obj del /F .\exceptions\*.obj
	@-if exist .\interfaces\*.obj del /F .\interfaces\*.obj
	@-if exist .\range\*.obj del /F .\range\*.obj

test_enumerator:	test_enumerator.exe
	@echo Testing enumerator
	@test_enumerator.exe

test_list:	test_list.exe
	@echo Testing list
	@test_list.exe

test_map:	test_map.exe
	@echo Testing map
	@test_map.exe

test_queue:	test_queue.exe
	@echo Testing queue
	@test_queue.exe

test_set:	test_set.exe
	@echo Testing set
	@test_set.exe

test_stack:	test_stack.exe
	@echo Testing stack
	@test_stack.exe

test_vector:	test_vector.exe
	@echo Testing vector
	@test_vector.exe

test_intrange:	test_intrange.exe
	@echo Testing intrange
	@test_intrange.exe

test_ranges:	test_ranges.exe
	@echo Testing ranges
	@test_ranges.exe

test_interfaces:	test_interfaces.exe
	@echo Testing interfaces
	@test_interfaces.exe

COMMON_OBJS		=									\
				common.obj							\
				memory.obj							\
				utility.obj							\
				exceptions\exceptions.obj			\
				functions\categories.obj			\
				range\categories.obj				\
				range\filters.obj					\
				intrange.obj					\
													\
				interfaces\container.obj			\
				interfaces\objectcontainer.obj		\
													\
				std_box.obj							\
				std_boxutil.obj						\
				std_type_type_traits.obj			\
													\

CONTAINER_OBJS	=									\
													\
				list.obj							\
				map.obj								\
				queue.obj							\
				set.obj								\
				stack.obj							\
				vector.obj							\
													\


$(DTL_LIB):	$(COMMON_OBJS) $(CONTAINER_OBJS)
	$(AR) -c $@ $(COMMON_OBJS) $(CONTAINER_OBJS)

std_box.obj:	$(SYNSOFT_D_PHOBOS_ROOT)\std\box.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ $(SYNSOFT_D_PHOBOS_ROOT)\std\box.d

std_boxutil.obj:	$(SYNSOFT_D_PHOBOS_ROOT)\std\boxutil.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ $(SYNSOFT_D_PHOBOS_ROOT)\std\boxutil.d

std_type_type_traits.obj:	$(SYNSOFT_D_PHOBOS_ROOT)\std\type\traits.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ $(SYNSOFT_D_PHOBOS_ROOT)\std\type\traits.d


memory.obj: memory.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ memory.d

interfaces\container.obj: interfaces\container.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ interfaces\container.d

interfaces\objectcontainer.obj: interfaces\objectcontainer.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ interfaces\objectcontainer.d

range\categories.obj: range\categories.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ range\categories.d

range\filters.obj: range\filters.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ range\filters.d

common.obj: common.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ common.d

utility.obj: utility.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ utility.d

exceptions\exceptions.obj: exceptions\exceptions.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ exceptions\exceptions.d

functions\categories.obj: functions\categories.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ functions\categories.d

intrange.obj: range\intrange.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ range\intrange.d

list.obj: containers\list.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\list.d

map.obj: containers\map.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\map.d

queue.obj: containers\queue.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\queue.d

set.obj: containers\set.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\set.d

stack.obj: containers\stack.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\stack.d

vector.obj: containers\vector.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ containers\vector.d


enumerator_test.obj: test\enumerator_test.d interfaces\container.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\enumerator_test.d

list_test.obj: test\list_test.d list.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\list_test.d

map_test.obj: test\map_test.d map.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\map_test.d

queue_test.obj: test\queue_test.d queue.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\queue_test.d

set_test.obj: test\set_test.d set.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\set_test.d

stack_test.obj: test\stack_test.d stack.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\stack_test.d

vector_test.obj:	test\vector_test.d vector.obj
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\vector_test.d

intrange_test.obj: test\intrange_test.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\intrange_test.d

ranges_test.obj: test\ranges_test.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\ranges_test.d

interfaces_test.obj: test\interfaces_test.d
	$(DMD) $(DINCLUDE) $(DMD_DEBUG_ARGS) -of$@ test\interfaces_test.d


test_enumerator.exe:	enumerator_test.obj  $(DTL_LIB)
	$(LD) enumerator_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB) -L/NOLOGO

test_list.exe:	list_test.obj $(DTL_LIB)
	$(LD) list_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB) -L/NOLOGO

test_map.exe:	map_test.obj $(DTL_LIB)
	$(LD) map_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_queue.exe:	queue_test.obj $(DTL_LIB)
	$(LD) queue_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_set.exe:	set_test.obj $(DTL_LIB)
	$(LD) set_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_stack.exe:	stack_test.obj $(DTL_LIB)
	$(LD) stack_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_vector.exe:	vector_test.obj $(DTL_LIB)
	$(LD) vector_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_intrange.exe:	intrange_test.obj $(DTL_LIB)
	$(LD) intrange_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_ranges.exe:	ranges_test.obj $(DTL_LIB)
	$(LD) ranges_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

test_interfaces.exe:	interfaces_test.obj $(DTL_LIB)
	$(LD) interfaces_test.obj -of$@ snn.lib phobos.lib $(DTL_LIB)

