#*******************************************************************************
#* 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 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

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

# Libraries
lib: .libraries

# tests Stub to add tests
tests: 
	@$(MAKE) -f ./test/PAUnitTest2/armv7/linux/build/makefile all

# examples Stub to add Examples
examples: 
	@$(MAKE) -f ./example/simpleExample2/armv7/build/makefile all

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

$(ARMV7LIBDIR)/libpa.a:
	@$(MAKE) -f ./lib/libpa_aearmv7.mk $@

# Rule to clean $(ARMV7LIBDIR)/libpa.a library
clean:
	@$(MAKE) -f ./lib/libpa_aearmv7.mk $@
	@$(RM) $(ARMV7LIBDIR)/libpa.a
	@$(MAKE) -f ./example/simpleExample2/armv7/build/makefile clean
	@$(MAKE) -f ./test/PAUnitTest2/armv7/linux/build/makefile clean
	@$(RMDIR) $(ARMV7OBJDIR)/pa
	@$(RMDIR) $(ARMV7BINDIR)/pa

