#----------------------------------------------------------------------------
# Copyright (C)Nintendo All rights reserved.
#
# These coded instructions, statements, and computer programs contain proprietary
# information of Nintendo and/or its licensed developers and are protected by
# national and international copyright laws. They may not be disclosed to third
# parties or copied or duplicated in any form, in whole or in part, without the
# prior written consent of Nintendo.
# 
# The content herein is highly confidential and should be handled accordingly.
#----------------------------------------------------------------------------

ifeq ($(NW_BUILD), Release)
APP_IS_DEBUG        := 0
APP_TARGET			:= Release
else
ifeq ($(NW_BUILD), Debug)
APP_IS_DEBUG        := 1
APP_TARGET			:= Debug
else
APP_IS_DEBUG        := 1
APP_TARGET			:= Develop
endif
endif

APP_OUT             := ./obj/$(APP_TARGET)

TEXCVTR := ../../../../../Tools/Graphics/3dTools/3dTextureConverter.exe
BINCVTR := ../../../../../Tools/Graphics/3dTools/3dBinaryConverter.exe

TARGET  := 1

.PHONY: default build all clean clobber resources install run stop

default:run

build:
	ndk-build -j4 NDK_DEBUG=$(APP_IS_DEBUG) NDK_OUT=$(APP_OUT) NDK_TOOLCHAIN_VERSION=clang
	ant debug

all:project resources run

install:build
	adb install -r bin/g3d-simple-debug.apk

uninstall:
	adb uninstall com.example.g3d_simple

run:install
	adb shell am start -n com.example.g3d_simple/android.app.NativeActivity

stop:
	adb shell am force-stop com.example.g3d_simple

clean:
	rm -rf ./obj/$(APP_TARGET)

clobber:
	rm -rf ./assets/human.bfres
	rm -rf ./obj
	rm -rf ./libs
	rm -rf ./bin

resources:
	@rm -rf human command
	@cp -r ../G3dDemo/Resources/human human
	$(TEXCVTR) --platform=generic human/textures/human_A.ftxb -o=human/textures/human_A.ftxb -f=srgb_8_8_8_8
	$(TEXCVTR) --platform=generic human/textures/human_B.ftxb -o=human/textures/human_B.ftxb -f=srgb_8_8_8_8
	$(TEXCVTR) --platform=generic human/textures/human_mini_eye_l.0.ftxb -o=human/textures/human_mini_eye_l.0.ftxb -f=srgb_8_8_8_8
	@rm -rf command
	@echo "-o=./assets/human.bfres" > command
	@find human -type f -iname "human*" >> command
	$(BINCVTR) @command
	@rm -rf human command

project:
	android.bat update project -t $(TARGET) -p ./ -n g3d-simple

clean_project:clobber
	rm -rf build.xml local.properties proguard-project.txt project.properties
