# Makefile - makefile for TIPC
#
# Copyright (c) 2004-2009 Wind River Systems, Inc.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. Neither the names of the copyright holders nor the names of its
#    contributors may be used to endorse or promote products derived from
#    this software without specific prior written permission.
#
# Alternatively, this software may be distributed under the terms of the
# GNU General Public License ("GPL") version 2 as published by the Free
# Software Foundation.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#  
#
# modification history
# --------------------
# 02b,05jan12,h_x  Remove tipc_lib.c from Doc because of conflicting with sockLib
# 02a,22apr09,h_w  Changed GNU optimization back to level 3.
# 01z,21jan09,h_w  Changed GNU optimization level 0.
# 01y,10dec08,h_w  Add compatible vxWorks6.6 SMP conditional.
# 01x,07jul08,jpb  Changed SMP conditional.
# 01w,10oct07,ebh  Add tipc_native.c to the DOC definition
# 01v,13jul07,mze  removed build options now in tipc.h to support SOURCE_ONLY flag
# 01u,04jul07,bwa  removed SMP compilation of sm_media and dshm_media
# 01t,09may07,mze  removed tipc_net_subscr.o and changed some comments
# 01s,12jan07,bwa  added dSHM media.
# 01r,15dec06,mze  renamed tipc_subscr to tipc_topsrv
# 01q,02dec06,mze  Added flags for footprint reduction and changed WV instrumentation to match
# 01p,14nov06,mze  Add new file structure for 1.7.1 merge
# 01o,19Jul06,ebh  Add conditional compile of WV instrumentation
# 01n,03Feb06,mze  Adding tipc_cfgsrv.o
# 01m,16nov05,ebh  Port of SF TIPC 1.6 code base
# 01l,20sep05,mze  add docs to tipcShow.c
# 01k,15jul05,dsk  add TIPC socket backend (tipcSockLib.o tipcSockUtilLib.o)
# 01j,15apr05,als  disable virtual stack build; remove Gnu warning suppression
# 01i,08apr05,als  added licensing info
# 01h,29mar05,bwa  added sm_media.o
# 01g,25feb05,als  add apigen support
# 01f,16feb05,als  remove warning suppression for type mismatch
# 01e,07feb05,als  modified to reflect changes in Base 6 build environment
# 01d,14sep04,als  suppress additional Diab warnings for known non-problems
# 01c,03sep04,als  incorporated code inspection feedback
# 01b,07aug04,p_r  code update
# 01a,22jul04,eh   written
#
# DESCRIPTION
# This file contains the makefile rules for building the TIPC library.
#

# specify name and location of TIPC library

TGT_DIR = $(WIND_BASE)/target
LIB_BASE_NAME = tipc

# Including defs.library to see if _WRS_CONFIG_SMP is defined.
# It must be after LIB_BASE_NAME
include $(TGT_DIR)/h/make/defs.library

# 'make' must search this directory to find the public TIPC .h files

EXTRA_INCLUDE += -I. -I$(WIND_BASE)/target/h/tipc  

# the following compiler options are for BSP builds only as TIPC is 
# now SOURCE_ONLY for project based builds

# if you want a minimum TIPC footprint use make TIPC_FLAGS=-MIN   
ifeq (MIN,$(findstring MIN,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_MIN
endif
 
	
# if you want a to select individual TIPC footprint options use make 
# TIPC_FLAGS=-NO_DEBUG-NO_SYS_MSGS-NO_CFG_SERVICE-NO_SOCKET-NO_MB-NO_PRE_17

# compile without multi bearer capabilities
ifeq (NO_MB,$(findstring NO_MB,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_MB  
endif 
 
# compile without the debug messaging capabilities
ifeq (NO_DEBUG,$(findstring NO_DEBUG,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_DEBUG  
endif

# compile without the system messaging capabilities
ifeq (NO_SYS_MSGS,$(findstring NO_SYS_MSGS,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_SYS_MSGS 
endif

# compile without the configuration service capabilities
ifeq (NO_CFG,$(findstring NO_CFG,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_CFG  
endif

# compile without the socket API
ifeq (NO_SOCKET,$(findstring NO_SOCKET,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_SOCKET 
endif

# compile without backwards compatibility to pre 1.7 nodes
ifeq (NO_PRE_17,$(findstring NO_PRE_17,$(TIPC_FLAGS)))
	ADDED_CFLAGS +=  -DTIPC_NO_PRE_17 
endif
	   

# to add the WV instrumentation for TIPC 
# ADDED_CFLAGS+=-DWV_TIPC

# specify list of object files to be built BSP ONLY
# PRJ builds use list of .o's in 20comp_tipc.cdf
# keep these lists the same!

OBJS =  tipc_addr.o tipc_bcast.o \
	tipc_bearer.o tipc_cfgsrv.o tipc_config_show.o \
	tipc_core.o tipc_dbg.o tipc_discover.o \
	tipc_eth_media.o tipc_handler.o \
	tipc_locklib.o tipc_link.o tipc_msg.o \
	tipc_name_distr.o tipc_name_table.o tipc_net.o \
	tipc_node.o tipc_port.o tipc_ref.o tipc_sk_buff.o \
	tipc_socket.o tipc_socklib.o \
	tipc_topsrv.o tipc_user_reg.o tipc_wvlib.o 

ifndef _WRS_CONFIG_SMP
ifneq (SMP,$(findstring SMP,$(VXBUILD)))
OBJS += tipc_sm_media.o tipc_dshm_media.o
endif
endif

# specify list of files from which man pages are generated

DOC_FILES = tipc_config_show.c tipc_native.c

# use standard rules for building a library (except as noted below)

include $(TGT_DIR)/h/make/rules.library

# override some variable definitions
# - force maximum optimization to ensure inlining occurs
# - suppress compiler warnings associated with TIPC core files
#   if they aren't really problems
#   GNU:
#   - no warning suppression performed at this time
#   DIAB:
#   - allow void pointer arithmetic
#     [ie. (void *) - (void *) treated same as (char *) - (char *)]
#   - suppress warning when compiler can't do requested inlining

ifeq ($(TOOL_FAMILY),gnu)
	CC_OPTIM = -O3
else 
        CC_OPTIM = -O -XO
endif

include $(TGT_DIR)/h/make/config/comps/tipc/defs.docs
