#*******************************************************************************
#* FILE PURPOSE: Top level makefile for Creating Component Libraries for ARM
#* architectures
#*******************************************************************************
#* FILE NAME: makefile
#*
#* DESCRIPTION: Defines Compiler tools paths, libraries , Build Options 
#*
#*
#*******************************************************************************
#*
# (Mandatory) Specify where various tools are installed.

# Output for prebuilt generated libraries
export ARMV7LIBDIR ?= ./lib
export ARMV7OBJDIR ?= ./obj
export ARMV7OBJDIR_SO := $(ARMV7OBJDIR)/pktlib/lib_so
export ARMV7OBJDIR := $(ARMV7OBJDIR)/pktlib/lib
export ARMV7BINDIR ?= ./bin

# ROOT Directory
export ROOTDIR := ../../..


# INCLUDE Directory
export INCDIR := ../;$(PDK_INSTALL_PATH);$(ROOTDIR)

# Common Macros used in make

ifndef RM
export RM = rm -f
endif

ifndef CP
export CP = cp -p
endif

export MKDIR = mkdir -p

ifndef RMDIR
export RMDIR = rm -rf
endif

ifndef SED
export SED = sed
endif

ifndef MAKE
export MAKE = make
endif

# PHONY Targets
.PHONY: all clean lib tests examples install

# all rule
all: .executables install
.executables: lib tests examples

#Libraries
lib: .libraries

# Make rule to create $(ARMV7LIBDIR)/libpktlib.a library
.libraries: $(ARMV7LIBDIR)/libpktlib.a libpktlib.so

$(ARMV7LIBDIR)/libpktlib.a:
	-@echo Calling make lib with $@
	@$(MAKE) -f ./lib/libpktlib_aearmv7.mk $@

libpktlib.so:
	-@echo Calling make lib with $@
	@$(MAKE) -f ./lib/libpktlib_aearmv7.mk $@
# Rule to clean $(ARMV7LIBDIR)/libpktlib.a library
clean:
	@$(MAKE) -f ./lib/libpktlib_aearmv7.mk $@
	@$(RM) $(ARMV7LIBDIR)/libpktlib.a
	@$(RM) $(ARMV7LIBDIR)/libpktlib.so*

install:
	echo inc base dir $(INSTALL_INC_BASE_DIR)
	install -d $(INSTALL_INC_BASE_DIR)/ti/runtime/pktlib
	install -d $(INSTALL_LIB_BASE_DIR)
	$(CP) ./*.h                $(INSTALL_INC_BASE_DIR)/ti/runtime/pktlib
	@$(CP) -r $(ARMV7LIBDIR)/libpktlib.a         $(INSTALL_LIB_BASE_DIR)
	@$(CP) -rp $(ARMV7LIBDIR)/libpktlib.so*      $(INSTALL_LIB_BASE_DIR)

# Make rule to create tests/examples Stub
examples tests:
