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

USES_RM = 1

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

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

include $(SRCDIR)/Make.common

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

# 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

# CLIBSRCS/CPPLIBSRCS specifies all C/C++ files that are built and linked into 
# the library; use definitions already in Make.common
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

INCLUDES += \
	    -I$(P2P_INC_ROOT) \
	    -I$(P2P_PRIV_INC_ROOT) \
	    -I./../../../include # for private/iostypes.h, private/iosresclt.h, etc. 

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)

P2P_HFILES={p2p.h,p2p_errors.h,p2p_priv.h,p2p_priv_t.h}
P2P_PRIV_HFILES={p2p_rm.h,p2p_ios.h,p2p_impl.h}
P2P_VOICE_HFILES=voice_rm.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 -m 440 $(GBA_SOURCE)/sw/common/lib/p2p/$(P2P_HFILES) $(P2P_INC_ROOT)
	$(INSTALL) -p -m 440 $(GBA_SOURCE)/sw/common/lib/p2p/$(P2P_PRIV_HFILES) $(P2P_PRIV_INC_ROOT)
	$(INSTALL) -p -m 440 $(GBA_SOURCE)/sw/common/lib/p2p/voice/$(P2P_VOICE_HFILES) $(P2P_INC_ROOT)
