# 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=libFslGraphicsGLES3_1

SOURCES=\
  source/FslGraphicsGLES3_1/GLProgramPipeline.cpp \
  source/FslGraphicsGLES3_1/GLShaderProgram.cpp 

INCLUDE_DIRS=\
  include \
  $(FSL_GRAPHICS_SDK)/DemoFramework/FslBase/include \
  $(FSL_GRAPHICS_SDK)/DemoFramework/FslGraphics/include \
  $(FSL_GRAPHICS_SDK)/DemoFramework/FslGraphicsGLES3/include

CPP_DEFINE_FLAG_NAMES=\
  FSL_ENABLE_GRAPHICS_ES3 \
  FSL_ENABLE_OPENGLES3_1 \
  GL_GLEXT_PROTOTYPES

# 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 += $(CPPFLAGS_EXT) -DDEBUG -D_DEBUG
CFLAGS   += $(CFLAGS_EXT) -g -O0
CXXFLAGS += $(CXXFLAGS_EXT) -g -O0
LDFLAGS  += $(LDFLAGS_EXT) -g
else ifeq ($(config),Release)
TARGET_POSTFIX=
CPPFLAGS += $(CPPFLAGS_EXT) -DNDEBUG
CFLAGS   += $(CFLAGS_EXT) -O3
CXXFLAGS += $(CXXFLAGS_EXT) -O3
LDFLAGS  += $(LDFLAGS_EXT)
else ifneq (,$(config))
$(warning Unknown configuration "$(config)")
endif
# Use "make RANLIB=''" for platforms without ranlib.
RANLIB ?= ranlib



VIVANTE_PATH_INCLUDE = $(SYSROOT)/usr/include/vivante
TARGET_PATH_INCLUDE  = $(SYSROOT)/usr/include

OBJ_PATH=build/Yocto/obj/$(config)

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_UBUNTU
#REQUIRED_CXX_FLAGS += -mfpu=vfpv3-d16
REQUIRED_CXX_FLAGS += -fno-strict-aliasing -fno-optimize-sibling-calls
REQUIRED_CXX_FLAGS += $(CFLAGS_EGL)
REQUIRED_CXX_FLAGS += -DLINUX
REQUIRED_CXX_FLAGS += \
	-I$(VIVANTE_PATH_INCLUDE) \
	-I$(TARGET_PATH_INCLUDE) \
	-I$(COMMON_DIR)/inc

  
all: $(TARGET)

# $@ for the pattern-matched target
$(TARGET): $(OBJECTS)
	$(AR) Urcu $@ $(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
