# AUTOGENERATED by FslBuildGen 
# Any manual changes to it will be lost if its regenerated.
#
# Please modify the 'Fsl.gen' file instead
#
# You may define standard make variables such as CFLAGS or
# CXXFLAGS to affect the build. For example, you could use:
#
#      make CXXFLAGS=-g
#
# to build with debug information. The full list of variables
# that can be used by this makefile is:
# AR, CC, CFLAGS, CPPFLAGS, CXX, CXXFLAGS, LD, LDFLAGS, MAKE, RANLIB.

# You may also specify config=Debug|Release
# or their corresponding lower case variants on make command line to select
# the corresponding default flags values.

TARGET_NAME=##PACKAGE_TARGET_NAME##

SOURCES=##PACKAGE_SOURCE_FILES## 

INCLUDE_DIRS=##PACKAGE_INCLUDE_DIRS##

CPP_DEFINE_FLAG_NAMES=##PACKAGE_CPP_FLAGS##

# Stuff below is basically the same for all builds

SHELL = /bin/sh

CC ?= $(CROSS_COMPILE)gcc
AR ?= $(CROSS_COMPILE)ar
CXX ?= $(CROSS_COMPILE)g++

# Default to a release build
config ?= Release
 
ifeq ($(config),debug)
override config := Debug
endif
ifeq ($(config),release)
override config := Release
endif
ifeq ($(config),Debug)
TARGET_POSTFIX=_d
CPPFLAGS += -DDEBUG -D_DEBUG
CFLAGS += -g -O0
CXXFLAGS += -g -O0
LDFLAGS += -g
else ifeq ($(config),Release)
TARGET_POSTFIX=
CPPFLAGS += -DNDEBUG
CFLAGS += -O3
CXXFLAGS += -O3
else ifneq (,$(config))
$(warning Unknown configuration "$(config)")
endif
# Use "make RANLIB=''" for platforms without ranlib.
RANLIB ?= ranlib

##PACKAGE_VARIANT_SECTION##

TARGET_PATH_LIB = $(ROOTFS)/usr/lib
TARGET_PATH_INCLUDE = $(ROOTFS)/usr/include
 
OBJ_PATH=##PACKAGE_OBJECT_PATH##

TARGET=$(OBJ_PATH)/$(TARGET_NAME)$(TARGET_POSTFIX).a
OBJECTS = $(patsubst %.cpp,$(OBJ_PATH)/%.o,$(SOURCES)) 
OBJECTS_DEPS = $(OBJECTS:.o=.d)
INCLUDE_DIR_PARAMS=$(foreach d,$(INCLUDE_DIRS),-I$d)
CPP_DEFINE_FLAG_PARAMS=$(foreach d,$(CPP_DEFINE_FLAG_NAMES),-D$d)

REQUIRED_CXX_FLAGS = -Wall -Wtype-limits -Wuninitialized -fPIC -DPIC -std=c++11 -g $(CPP_DEFINE_FLAG_PARAMS) -pthread -DFSL_PLATFORM_YOCTO
REQUIRED_CXX_FLAGS += -fno-strict-aliasing -fno-optimize-sibling-calls
REQUIRED_CXX_FLAGS += $(CFLAGS_EGL)
REQUIRED_CXX_FLAGS += -DLINUX
REQUIRED_CXX_FLAGS += \
	-I$(TARGET_PATH_INCLUDE) \
	-I$(COMMON_DIR)/inc

  
all: $(TARGET)

# $@ for the pattern-matched target
$(TARGET): $(OBJECTS)
	$(AR) rc $@ $(OBJECTS)
	$(RANLIB) $@

# Simple rule used for "cleaning" the build environment.
clean:
	@-rm -f $(OBJECTS)
	@-rm -f $(OBJECTS_DEPS)
	@-rm -f $(TARGET)
	@-rm -f gmon.out

install: all
	@echo ok
  
# Pattern Rule
# $@ for the pattern-matched target
# $< for the pattern-matched dependency
$(OBJ_PATH)/%.o : %.cpp
	@mkdir -p $(@D)
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(REQUIRED_CXX_FLAGS) $(INCLUDE_DIR_PARAMS) -o $@ -c $<

# All this is apparently needed for proper Autodependencies with GNU make
$(OBJ_PATH)/%.d: %.cpp
	@mkdir -p $(@D)
	@rm -f $@;
	@$(CXX) -M $(CPPFLAGS) $(CXXFLAGS) $(REQUIRED_CXX_FLAGS) $(INCLUDE_DIR_PARAMS) $< > $@
	@mv -f $@ $@.tmp
	@sed -e 's|.*:|$(@D)/$(*F).o:|' < $@.tmp > $@
	@sed -e 's/.*://' -e 's/\\$$//' < $@.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@
	@rm -f $@.tmp
	
# pull in dependency info for *existing* .o files
-include $(OBJECTS_DEPS)
	
.PHONY : all clean
