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

# This the DDS Makefile for MacOS and the clang compiler.
# It creates a statically linked library, libdds.a.

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

# You can configure the following:

# 1. The threading systems that you want in the library.
# 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 and WINAPI don't work on Windows.
THR_BOOST	= -DDDS_THREADS_BOOST
THR_GCD		= -DDDS_THREADS_GCD
THR_OPENMP	= -DDDS_THREADS_OPENMP
THR_WINAPI	= -DDDS_THREADS_WINAPI
THR_STL		= -DDDS_THREADS_STL

THREADING	= $(THR_BOOST) $(THR_GCD) $(THR_STL)

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

CC_BOOST	= /usr/local/Cellar/boost/1.56.0
CC_BOOST_INCL	= $(CC_BOOST)/include
CC_BOOST_LINK	= -L$(CC_BOOST)/lib -lboost_system -lboost_thread-mt

THREAD_COMPILE	= 
THREAD_LINK	= $(CC_BOOST_LINK)

# 2. 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. 2 and no. 3 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_o.txt

# If your compiler name is not given here, change it.
CC		= g++

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

WARN_FLAGS	= 		\
	-Wshadow 		\
	-Wsign-conversion 	\
	-pedantic -Wall -Wextra  \
	-Wcast-align -Wcast-qual \
	-Wctor-dtor-privacy 	\
	-Wdisabled-optimization \
	-Winit-self 		\
	-Wmissing-declarations 	\
	-Wmissing-include-dirs 	\
	-Wcomment 		\
	-Wold-style-cast 	\
	-Woverloaded-virtual 	\
	-Wredundant-decls 	\
	-Wsign-promo 		\
	-Wstrict-overflow=1 	\
	-Wswitch-default -Wundef \
	-Werror 		\
	-Wno-unused 		\
	-Wno-unknown-pragmas 	\
	-Wno-long-long		\
	-Wno-format

COMPILE_FLAGS	= -O3 -flto -mtune=generic -std=c++11 \
		$(WARN_FLAGS) \
		$(DDS_BEHAVIOR) $(THREAD_COMPILE) $(THREADING)

DLLBASE		= dds
STATIC_LIB	= lib$(DLLBASE).a

include $(INCL_SOURCE)

O_FILES 	= $(subst .cpp,.o,$(SOURCE_FILES))


macos:	$(O_FILES)
	ar rcs $(STATIC_LIB) $(O_FILES)

%.o:	%.cpp
	$(CC) $(COMPILE_FLAGS) -c $<

depend:
	makedepend -Y -- $(SOURCE_FILES)

clean:
	rm -f $(O_FILES) $(STATIC_LIB)

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

include $(INCL_DEPENDS)

