# --------------------- INFORMATION --------------------------------

# This the DDS Makefile for Windows and the Microsoft Visual C++
# compiler.  It assumes a Unix-like setup for some commands.

# The "windres" and "cvtres" tools are used for putting version
# information into the DLL in a way that Windows can see.
# It is not mandatory, and if you don't have those tools,
# You can remove $(VFILE).obj in the target line below.

# --------------------- CONFIGURATION ------------------------------

# You can configure the following:
#
# 1. The location of the Boost libraries (you can leave the
# variables blank if you don't have or want Boost).  All that
# matters are CC_BOOST_INCL and CC_BOOST_LINK.
# On my systems (there are two), they are here:

BOOST32_PATH1	= \Users\heins\Libraries\Boost\boost_1_66_0_x32_new
BOOST32_LIB1	= $(BOOST32_PATH1)\lib32-msvc-14.1

BOOST32_PATH2	= \Users\s.hein\Documents\Programs\boost_1_66_0_x32_14_1
BOOST32_LIB2	= $(BOOST32_PATH2)\lib32-msvc-14.1

CC_BOOST_INCL	= /I$(BOOST32_PATH1) /I$(BOOST32_PATH2)
CC_BOOST_LINK	= /link /LIBPATH:$(BOOST32_LIB1) /LIBPATH:$(BOOST32_LIB2)

# 2. The threading systems that you want in the DLL/executable.
# You will always get single-threading.  If you have multiple
# threading systems, the default will be the multi-threading one
# with the lowest number (see System.cpp).  All that matters is
# CC_THREADING.

# GCD doesn't work on Windows.
THR_WINAPI	= /DDDS_THREADS_WINAPI
THR_OPENMP	= /DDDS_THREADS_OPENMP
THR_GCD		= /DDDS_THREADS_GCD
THR_BOOST	= /DDDS_THREADS_BOOST
THR_STL  	= /DDDS_THREADS_STL
THR_TBB  	= /DDDS_THREADS_TBB
THR_STLIMPL  	= /DDDS_THREADS_STLIMPL
THR_PPLIMPL  	= /DDDS_THREADS_PPLIMPL

THREADING	= $(THR_BOOST) $(THR_OPENMP) $(THR_WINAPI) \
		$(THR_STL) $(THR_STLIMPL) $(THR_PPLIMPL)

# If you need to add something for a threading system, this is
# the place.

THREAD_COMPILE	= /openmp $(CC_BOOST_INCL)
THREAD_LINK	= $(CC_BOOST_LINK)

# 3. Debugging options.  (There are more granular options in debug.h.)

DEBUG_ALL	= /DDDS_DEBUG_ALL 
TIMING		= /DDDS_TIMING
SCHEDULER	= /DDDS_SCHEDULER

# All that matters from no. 3 and no. 4 is the following.  Here you
# can add $(SMALL_MEMORY) etc.

DDS_BEHAVIOR	= 

# ----------------------- OFTEN OK    ------------------------------

# From here on you you don't have to change anything to CONFIGURE
# the compilation.  But you may well have to change something to 
# get it to compile.

INCL_SOURCE	= Makefiles/sources.txt
INCL_DEPENDS	= Makefiles/depends_obj.txt

# If your Microsoft compiler is not called cl, change it here.
CC		= cl

# We compile with aggressive warnings, but we have to turn off some
# of them as they appear in Windows libraries in great numbers...

WARN_FLAGS	=		\
	/Wall			\
	/wd4365			\
	/wd4464			\
	/wd4514			\
	/wd4555			\
	/wd4571			\
	/wd4623			\
	/wd4625			\
	/wd4626			\
	/wd4668			\
	/wd4710			\
	/wd4711			\
	/wd4774			\
	/wd4820			\
	/wd4996			\
	/wd5026			\
	/wd5027			\
	/WX

# If you don't have /std:c++17, you won't get THR_STLIMPL.

COMPILE_FLAGS	= /O2 /Oi /Ot /Oy /Ox /GL /EHs /std:c++17 \
		$(WARN_FLAGS) \
		$(DDS_BEHAVIOR) $(THREAD_COMPILE) $(THREADING)

LINK_FLAGS1	= /O2 /Oi /Ot /Oy /GL /EHs $(WARN_FLAGS)
LINK_FLAGS2	= $(THREAD_LINK)

DLLBASE		= dds
DLL 		= $(DLLBASE).dll
DLIB 		= $(DLLBASE).lib
EXPORTER	= Exports.def

VFILE		= ddsres

include $(INCL_SOURCE)

OBJ_FILES 	= $(subst .cpp,.obj,$(SOURCE_FILES)) $(VFILE).obj

vs:	$(OBJ_FILES)
	$(CC) $(LINK_FLAGS1) $(OBJ_FILES) $(EXPORTER) \
	$(LINK_FLAGS2) /out:$(DLL)

%.obj:	%.cpp
	$(CC) $(COMPILE_FLAGS) /c $<

$(DLLBASE).res:	$(DLLBASE).rc
	windres $(DLLBASE).rc $(DLLBASE).res

$(VFILE).obj:	$(DLLBASE).res
	cvtres /MACHINE:X86 /OUT:$(VFILE).obj $(DLLBASE).res

depend:
	makedepend -Y -o.obj -- $(SOURCE_FILES)

clean:
	rm -f $(OBJ_FILES) $(DLL) $(DLLBASE).{lib,exp,def,obj,res}

install:
	test -d ../test || mkdir ../test
	test -d ../examples || mkdir ../examples
	cp $(DLL) $(DLIB) ../test
	cp $(DLL) $(DLIB) ../examples

# If you don't have a Linux-like setup, use "del" instead of "rm"
# and "copy" instead of "cp".

include $(INCL_DEPENDS)

