##########@@@SOFT@@@WARE@@@COPY@@@RIGHT@@@###################################
# Copyright (C) 2005-2006 Intel Corporation. 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 name Intel Corporation nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# 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.
###################################@@@SOFT@@@WARE@@@COPY@@@RIGHT@@@##########


# If no configuration is specified
# force CFG to be Externalif build installed, or Internal otherwise


ifdef INTEL_DIALOGIC_BIN
CFG	=	External
else
CFG	=	Internal
endif

#####################################################################################
# Configuration: External
#####################################################################################
ifeq "$(CFG)" "External"

# If the Dialogic Environment variable has been set, use it
ifdef INTEL_DIALOGIC_INC
	CFG_INC = 	-I$(INTEL_DIALOGIC_INC)
else
	CFG_INC = 	-I/usr/dialogic/inc
endif

ifdef INTEL_DIALOGIC_LIB
        CFG_LIB = 	-L$(INTEL_DIALOGIC_LIB)
else
        CFG_LIB = 	-L/usr/dialogic/lib
endif

# Initialize other variables
OUTDIR          =       ./Release
OBJDIR		=	$(OUTDIR)
LIB_NAME	= 	libpdl
STATIC_LIB	=	$(LIB_NAME).a
OUTFILE         =       $(OUTDIR)/$(STATIC_LIB)
OBJ		=	$(OBJDIR)/pdl.o			\
			$(OBJDIR)/iptransport.o		\
			$(OBJDIR)/pdl_linux_version.o


# Build rules                                                                                                              
all: $(OUTFILE)

# Pattern rules

# Create the release dir if doesn't exist
$(OUTDIR):
	mkdir -p "$(OUTDIR)"

$(OUTFILE): $(OBJDIR)/pdl.o $(OBJDIR)/iptransport.o $(OBJDIR)/pdl_linux_version.o
	ar cru	$(OUTFILE) $(OBJDIR)/pdl.o $(OBJDIR)/iptransport.o $(OBJDIR)/pdl_linux_version.o

$(OBJDIR)/pdl.o: 
	gcc -c pdl.c -o "$(OBJDIR)/pdl.o" $(CFG_INC)

$(OBJDIR)/iptransport.o:
	g++ -c iptransport.cpp -o "$(OBJDIR)/iptransport.o" $(CFG_INC)

$(OBJDIR)/pdl_linux_version.o:
	gcc -c pdl_linux_version.c -o "$(OBJDIR)/pdl_linux_version.o" 

clean:
	rm -f $(OUTFILE)
	rm -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean

endif

##################################################################################
# Configuration: Internal
##################################################################################
ifeq "$(CFG)" "Internal"
top_reldir	=	../../../..
-include ./make.rules.mak


OUTDIR          =       $(PDL_LINUX_OBJECTS)
OBJDIR		=	$(PDL_LINUX_OBJECTS)
#SYS_LIB	=	$(IPDEMOS_IMPORT_LIB)
LIB_NAME        =       libpdl
STATIC_LIB      =       $(LIB_NAME).a
OUTFILE         =       $(OUTDIR)/$(STATIC_LIB)
#LIB            =       -lpthread
CFG_INC		=	-I$(PDL_LINUX_INC_EXT) -I$(IPDEMOS_IMPORT_INC)

OBJ             =       $(OBJDIR)/pdl.o         	\
	                $(OBJDIR)/iptransport.o		\
			$(OBJDIR)/pdl_linux_version.o
                                                                                                                             
# Build rules
all: $(OUTFILE)
                                                                                                                             
# Pattern rules

# Create the release dir if doesn't exist
$(OUTDIR):
	mkdir -p "$(OUTDIR)"
                                                                                                                             
$(OUTFILE): $(OBJDIR)/pdl.o $(OBJDIR)/iptransport.o $(OBJDIR)/pdl_linux_version.o
	ar cru  $(OUTFILE) $(OBJDIR)/pdl.o $(OBJDIR)/iptransport.o $(OBJDIR)/pdl_linux_version.o
                                                                                                                             
$(OBJDIR)/pdl.o:
	gcc -c $(PDL_LINUX_SRC)/pdl.c -o "$(OBJDIR)/pdl.o" $(CFG_INC)
                                                                                                                             
$(OBJDIR)/iptransport.o:
	g++ -c $(PDL_LINUX_SRC)/iptransport.cpp -o "$(OBJDIR)/iptransport.o" $(CFG_INC)

$(OBJDIR)/pdl_linux_version.o:
	gcc -c $(PDL_LINUX_SRC)/pdl_linux_version.c -o "$(OBJDIR)/pdl_linux_version.o"

                                                                                                                             
clean:
	rm -f $(OUTFILE)
	rm -f $(OBJ)

# Clean this project and all dependencies
cleanall: clean

endif

