#!/usr/bin/env omake
#----------------------------------------------------------------------------
# Project:  NintendoWare
# File:     OMakefile
#
# Copyright (C)2009-2012 Nintendo/HAL Laboratory, Inc.  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.
#
# $Revision: $
#----------------------------------------------------------------------------

# NintendoWare version check
NW_VERSION_MAJOR=2

if $(test -e $(NW4C_ROOT)/build/omake/version.om)
    include $(NW4C_ROOT)/build/omake/version
    export
    
.SUBDIRS: Shaders NW$(NW_VERSION_MAJOR)/Resources    
  
SUPPORTED_TARGETS   =   CTR-*.Process.MPCore.*

NW_LIBRARIES += libnw_h3d

H3D_ROOT=$(NW4C_ROOT)/h3d/demo
    
if $(equal $(NW_VERSION_MAJOR), 2)  
    H3D_ROOT=$(NW4C_ROOT)/demos/h3d
    export    
    
RESOURCES_ROOT = NW$(NW_VERSION_MAJOR)/Resources/bch

public.InstallFile(source, destination) =
    asource = $(absname $(source))
    adestination = $(absname $(destination))
    $(adestination) : $(asource)
        mkdir -p $(dirname $(adestination))
        cp $< $@
    return $(adestination)


TARGET_PROGRAM      =   nw4cSequence

ROM_SPEC_FILE       =   nw4cSequence.rsf

SOURCES[]           =   
                        main.cpp
                        movie.cpp
                        NW$(NW_VERSION_MAJOR)/scene.cpp
                        NW$(NW_VERSION_MAJOR)/system.cpp
                        NW$(NW_VERSION_MAJOR)/utility.cpp

INCLUDES[]         +=   $(CTRMW_MOBICLIP_ROOT)/sampledemos/helper   \
                        $(CTRMW_MOBICLIP_ROOT)/include/mw/mo    \
                        NW$(NW_VERSION_MAJOR)   \
                        ./

ROMFS_INSTALL_ROOT  =   $(CTRMW_MOBICLIP_ROOT)/resources/moflex_videos
  
SHADER_SOURCES[]    =
                        $(CTRMW_MOBICLIP_ROOT)/sampledemos/helper/helper_VShader.vsh
TARGET_SHADER       =   helper_VShader
HELPER_SHADER       =   $(ROMFS_INSTALL_ROOT)/helper_VShader.shbin
SPRITE_SHADER       =   $(absname Shaders/images/SpriteShader.shbin)    
    
RESOURCES[]         =
                        $(InstallFile $(RESOURCES_ROOT)/SharedData.bch, $(ROMFS_INSTALL_ROOT)/SharedData.bch )
                        $(InstallFile $(RESOURCES_ROOT)/DemoResource.bch, $(ROMFS_INSTALL_ROOT)/DemoResource.bch )
                        $(InstallFile $(SPRITE_SHADER), $(ROMFS_INSTALL_ROOT)/SpriteShader.shbin)
                        
if $(equal $(NW_VERSION_MAJOR), 2)  
    RESOURCES         += $(InstallFile $(RESOURCES_ROOT)/Actor0.bch, $(ROMFS_INSTALL_ROOT)/Actor0.bch )
    export
else                        
    RESOURCES         += $(InstallFile $(RESOURCES_ROOT)/ToyPierrot.bch, $(ROMFS_INSTALL_ROOT)/ToyPierrot.bch )
    export

ROMFS_DEPENDENCIES  =   $(RESOURCES) $(HELPER_SHADER)

CXXFLAGS           +=   --preinclude=pch.h
CCFLAGS            +=   -DNW_VERSION_MAJOR=$(NW_VERSION_MAJOR)

LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_MoflexDemuxer)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_MobiclipVideoDecoder)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_ImaAdpcmAudioDecoder)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_DspAdpcmAudioDecoder)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_FastAudioDecoder)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_FilterDeblocker)
LIBFILES            += $`(addprefix $(CTRMW_MOBICLIP_ROOT)$(DIRSEP)sampledemos$(DIRSEP)helper$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libmw_mo_helper)

include $(NW4C_ROOT)/build/omake/modulerules

build: $(DEFAULT_TARGETS)

resource: $(ROMFS_DEPENDENCIES)

DefineDefaultRules()
