###############################################################################
# Makefile for P2P Services Modules library
#
# Copyright 2007 BroadOn Communications Corp.  All rights reserved.
#
###############################################################################

USES_RM = 0

include ../../../../devroot/include/make/SDKdefs
include ../share/libraries_common.mk

SRCDIR = $(GBA_SOURCE)/sw/common/lib/p2p/modules

include $(SRCDIR)/Make.common

# module name should be set to the name of this subdirectory
MODULENAME	= p2p_modules

# This indicates to commondefs/modulerules as to where this directory is
# The selectable paths are restricted to limit the number of subtrees
# that are added to the SDK tree.
LIB		= TRUE

# Library building
# LIBNAME specifies the name of the library.  No suffix is required, as
# that will depend on whether this is a DEBUG build or not.
# The final name of the library will be $(LIBNAME)$(LIBSUFFIX)
LIBNAME		= p2p_servicesmodules

# CLIBSRCS/CPPLIBSRCS specifies all C/C++ files that are built and linked into 
# the library.
# ASMLIBSRCS are all assembly files that will be built and linked into the lib.
CLIBSRCS       = \
		 $(CFILES) 

# ends up being BUILD_ROOT, the core of MODULE_ROOT
REX_BUILDDIR = ../..

# modulerules contains the rules that will use the above variables 
# and dependencies below to construct the library and binaries specified.
include $(REVOLUTION_EXT_ROOT)/build/buildtools/modulerules

CCFLAGS_WARNING = -W padding,nounused

# TODO:  p2p_matchmaking_random.c recently switched to use SHR_malloc, which is
#        defined by shr_mem.h, which requires including the following two 
#        folders.
#        Whether p2p_matchmaking_random.c should continue to use SHR_malloc is
#        is a separate issue.
INCLUDES       += \
		 -I./../../../include \
		 -I./../share/include

INCLUDES       += \
		  -I"$(REVOLUTION_SDK_ROOT)/include/revolution" \
		  -I$(P2P_INC_ROOT) \
		  -I$(P2P_PRIV_INC_ROOT) 

setup:	
	@if [ -z '$(REVOLUTION_P2P_ROOT)' ]; then\
	    echo "You must establish environment variable REVOLUTION_P2P_ROOT before proceeding."; \
	    exit 1; \
	fi
	@if [ ! -w '$(REVOLUTION_P2P_ROOT)' -o ! -d '$(REVOLUTION_P2P_ROOT)' ]; then\
	    mkdir -p '$(REVOLUTION_P2P_ROOT)'; \
	fi
# $(SETUP_ROOTS) does not create directory $(DEP_ROOT), without which build will fail
	@mkdir -p $(DEP_ROOT)

# TODO: get rid of duplication: this information also appears in sw/common/lib/p2p/modules/Makefile
P2P_MODULES_HFILES={p2p_matchmaking_fastgroup.h,p2p_matchmaking_random.h,p2p_matchmaking_whitepage.h,p2p_matchmaking_whitepage_vnid.h}

headers:
	@if [ ! -w $(P2P_INC_ROOT) -o ! -d $(P2P_INC_ROOT) ]; then \
	    	mkdir -p $(P2P_INC_ROOT); \
	fi
	@if [ ! -w $(P2P_PRIV_INC_ROOT) -o ! -d $(P2P_PRIV_INC_ROOT) ]; then \
	    	mkdir -p $(P2P_PRIV_INC_ROOT); \
	fi
	$(INSTALL) -p $(GBA_SOURCE)/sw/common/lib/p2p/modules/$(P2P_MODULES_HFILES) $(P2P_INC_ROOT)
