#! make -f
#----------------------------------------------------------------------------
# Project:  ポケットモンスター　ダイヤモンド＆パール
# File:     Makefile
#
# Copyright 2005 GameFreak.inc  All rights reserved.
#
#----------------------------------------------------------------------------

#export	NITRO_DEBUG=TRUE
export MAKEROM_ROMSPEED=1TROM
#export MAKEROM_ROMSPEED=MROM

# NITROSDK3.0付属ののプリコンパイルを読み込まない
NITRO_NO_STD_PCHDR = True

################################################################################
#
#
#		マクロスイッチの定義など
#
#
################################################################################
#----------------------------------------------------------------------------
#	ロム作成用定義　（ＲＯＭ提出の際は有効にしてsrl作成）
#----------------------------------------------------------------------------
#NITRO_FINALROM = yes

#----------------------------------------------------------------------------
#	バージョン定義
#----------------------------------------------------------------------------
VER_FILE	=	version

include	$(VER_FILE)

#(PM_DEBUG == yes)のときのみデバッグバージョン
ifeq	($(PM_DEBUG),yes)
MACRO_FLAGS	+=	-DPM_DEBUG
endif

ifdef	PM_VERSION
MACRO_FLAGS	+=	-DPM_VERSION=$(PM_VERSION)
endif

ifdef	PM_LANG
MACRO_FLAGS	+=	-DPM_LANG=$(PM_LANG)
endif

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2006/09/07
# version ファイル内で PG5_WIFIRELEASE = yes が宣言されていたら、
# Wi-Fiの接続先をテストサーバからパブリックサーバに切り替える

ifeq	($(PG5_WIFIRELEASE),yes)
MACRO_FLAGS	+=	-DPG5_WIFIRELEASE
endif

#------------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2006/09/08
# version ファイル内で PG5_MARUMIX = yes が宣言されていたら、
# ゲーム中にLR同時押しでMarumi-Xにデータを転送

ifeq	($(PG5_MARUMIX),yes)
MACRO_FLAGS	+=	-DPG5_MARUMIX
endif

#------------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/02/13
# PG5_TRIAL が定義されていたら、体験版を make する

ifdef	PG5_TRIAL
MACRO_FLAGS	+=	-DPG5_TRIAL=$(PG5_TRIAL)
VERSION_DIR					= trial
OUT_VERSION_DIR				= tri
SCRIPTFILE					= scr_seq_trial.narc
EVENTFILE					= zone_event_trial.narc
FIELDMAPFILE				= land_data_trial.narc
else
SCRIPTFILE					= scr_seq_release.narc
EVENTFILE					= zone_event_release.narc
FIELDMAPFILE				= land_data_release.narc
endif

#------------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/02/28
# PG5_UKENGLISH が定義されていたら、ESRB Notice が表示されないように
# localize_spec_mark(LANG_ALL) imatake 2007/04/10
# アーカイブの置き場所を resouce 下に移動

OPDEMO_DIR_ENG				= src/resource/eng/opening_demo

ifdef	PG5_UKENGLISH
OPDEMO_NARC_ENG				= $(OPDEMO_DIR_ENG)/uk/op_demo.narc
else
OPDEMO_NARC_ENG				= $(OPDEMO_DIR_ENG)/us/op_demo.narc
endif

# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_KOREA) imatake 2007/09/03
# 韓国語版でも、明示的に指定すれば従来版とのセーブデータ互換を維持するように

ifeq	($(PG5_SAVEDATACOMPATIBLE),TRUE)
MACRO_FLAGS	+=	-DPG5_SAVEDATACOMPATIBLE=TRUE
else
MACRO_FLAGS	+=	-DPG5_SAVEDATACOMPATIBLE=FALSE
endif

# -----------------------------------------------------------------------------

#----------------------------------------------------------------------------
# LIBSYSCALL: Provided to every product by NINTENDO
#	システムライブラリの追加
#----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2006/10/11
# 言語・バージョンでlibsyscallとロムヘッダを切り換えるように変更
# localize_spec_mark(LANG_ALL) imatake 2007/02/13
# 言語・バージョンでタイトルやIPLバナーも切り換えるように変更
# localize_spec_mark(LANG_ALL) imatake 2007/02/14
# ロムサイズとロムバージョンの切り換えに対応
# localize_spec_mark(LANG_KOREA) imatake 2007/08/02
# 韓国向けROMの作成に対応
# localize_spec_mark(LANG_KOREA) imatake 2007/11/09
# 韓国向けを512M（Ver. 0〜）のみに

ifeq	($(PM_VERSION),VERSION_DIAMOND)
VERSION_DIR					?= diamond
OUT_VERSION_DIR				?= dia
INITIAL_CODE_VERSION		= D
else
VERSION_DIR					?= pearl
OUT_VERSION_DIR				?= pea
INITIAL_CODE_VERSION		= P
endif

ifeq	($(PM_LANG),LANG_ENGLISH)
INITIAL_CODE_LANGUAGE		= E
LANG_DIR	= eng
FOR_KOREA	= FALSE
else
ifeq	($(PM_LANG),LANG_FRANCE)
INITIAL_CODE_LANGUAGE		= F
LANG_DIR	= fra
FOR_KOREA	= FALSE
else
ifeq	($(PM_LANG),LANG_GERMANY)
INITIAL_CODE_LANGUAGE		= D
LANG_DIR	= ger
FOR_KOREA	= FALSE
else
ifeq	($(PM_LANG),LANG_ITALY)
INITIAL_CODE_LANGUAGE		= I
LANG_DIR	= ita
FOR_KOREA	= FALSE
else
ifeq	($(PM_LANG),LANG_SPAIN)
INITIAL_CODE_LANGUAGE		= S
LANG_DIR	= spa
FOR_KOREA	= FALSE
else
ifeq	($(PM_LANG),LANG_KOREA)
INITIAL_CODE_LANGUAGE		= K
LANG_DIR	= kor
FOR_KOREA	= TRUE
ROMSIZE		= 512M
ROMVERSION	= 0
endif
endif
endif
endif
endif
endif

OUT_DIR		= $(OUT_VERSION_DIR)/$(LANG_DIR)

ifdef PG5_TRIAL
TITLENAME			= '"PKMN DP DEMO"'
INITIAL_CODE		= Y23$(INITIAL_CODE_LANGUAGE)
else
TITLENAME			= '"POKEMON $(INITIAL_CODE_VERSION)"'
INITIAL_CODE		= A$(INITIAL_CODE_VERSION)A$(INITIAL_CODE_LANGUAGE)
endif

INITIAL_CODE_LOWER	= $(shell echo $(INITIAL_CODE) | tr -s [:upper:] [:lower:])

LIBSYSCALL			= resource/$(INITIAL_CODE)/libsyscall.a
ROMHEADER_TEMPLATE	= resource/$(INITIAL_CODE)/rom_header_$(INITIAL_CODE_LOWER).template.sbin
BANNERFILE			= resource/$(INITIAL_CODE)/pokemon_DS_$(VERSION_DIR).bnr

ifdef PG5_TRIAL
ROMVERSION			= 0
else
ifdef PG5_PRELOTCHECK
ROMVERSION			= 0xE0
else
ifeq	($(PM_LANG),LANG_KOREA)
ROMVERSION			= 0
endif
endif
endif

ifdef PG5_1GROM
ROMSIZE				?= 1G
ROMVERSION			?= 0
else
ROMSIZE				?= 512M
ROMVERSION			?= 5
endif

MAKEROM_FLAGS	+=	-DTITLENAME=$(TITLENAME)
MAKEROM_FLAGS	+=	-DROMSIZE=$(ROMSIZE)
MAKEROM_FLAGS	+=	-DROMVERSION=$(ROMVERSION)
MAKEROM_FLAGS	+=	-DROMHEADER_TEMPLATE=$(ROMHEADER_TEMPLATE)
MAKEROM_FLAGS	+=	-DBANNERFILE=$(BANNERFILE)
MAKEROM_FLAGS	+=	-DFOR_KOREA=$(FOR_KOREA)

# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/03/13
# ゲーム内にCVSのタグ（任意の文字列）を埋め込む仕組みを実装
# localize_spec_mark(LANG_ALL) imatake 2007/03/20
# CVSのタグをNOEの管理バージョンに変換して埋め込むように変更

PG5_BUILDTAG	?= NOTAG
PG5_BUILDTAG_	= $(shell echo $(PG5_BUILDTAG) | sed -e "s/..-\([0-9]\{6\}\)/20\1/")

ifeq	($(PM_DEBUG),yes)
MACRO_FLAGS		+=	-DPG5_BUILDTAG=\"$(PG5_BUILDTAG_)_$(INITIAL_CODE)_D\"
else
MACRO_FLAGS		+=	-DPG5_BUILDTAG=\"$(PG5_BUILDTAG_)_$(INITIAL_CODE)_R\"
endif

# -----------------------------------------------------------------------------

#----------------------------------------------------------------------------
#	インクルードファイルのディレクトリの追加
#----------------------------------------------------------------------------
LINCLUDES      = ./include/gflib \
				 ./include/library

#----------------------------------------------------------------------------
#	ライブラリディレクトリの追加
#----------------------------------------------------------------------------
NITRODWC_LIB_MODULES_   = bm account
NITRODWC_LIB_GSMODULES_ = 

LDEPENDS_NEF = $(NITRODWC_LIB_DEPENDS)

LLIBRARY_DIRS	= ./src/library/spl/$(NITRO_BUILDTYPE)

#イクニューモンコンポーネントのためのライブラリを追加 by Mori 2005.7.27
LLIBRARIES		= ./libjn_spl.a libwvr$(CODEGEN).a
#LINCLUDES      = ../gflib/include
#LLIBRARY_DIRS  = ../gflib/lib/$(NITRO_BUILDTYPE)
#LLIBRARIES     = libgf.a

# 任天堂Cryptライブラリを追加 by mituhara 2006.07.05
LLIBRARY_DIRS	+= ./src/library/crypto/$(NITRO_BUILDTYPE)
LLIBRARIES	+= ./libcrypto.a

#----------------------------------------------------------------------------
#	ロムスペックファイル読み込みのため追加
#----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/02/09
# rsfファイルを一つに統合
ROM_SPEC= pm_dp_ose.rsf
# -----------------------------------------------------------------------------

#----------------------------------------------------------------------------
#		lsfファイル読み込みのため追加 by matsuda
#----------------------------------------------------------------------------
LCFILE_SPEC	=	main.lsf

MAKELCF_FLAGS	+=	-DADDRESS_MAIN=0x02000000

#ifeq	($(NITRO_PLATFORM),TEG)
#MAKELCF_FLAGS	+=	-DADDRESS_MAIN=0x02004000
#else
#MAKELCF_FLAGS	+=	-DADDRESS_MAIN=0x02000000
#endif



#------------------------------------------------------#
# イクニューモンコンポーネントを追加 by Mori 2005.7.27
# VRAM内に無線ライブラリが配置されるコンポーネント定義 #
MY_COMPONENT_NAME	= ichneumon
MAKEROM_ARM7	= $(NITRO_COMPONENTSDIR)/$(MY_COMPONENT_NAME)/$(NITRO_BUILDTYPE_ARM7)/$(MY_COMPONENT_NAME)_sub$(TS_VERSION).nef
#------------------------------------------------------#

#----------------------------------------------------------------------------
#	ターゲットファイル設定
#----------------------------------------------------------------------------
#TARGET_NEF	=	main.nef	TARGET_BINに.srlを指定すると.nefも一緒に生成される
TARGET_BIN	=	main.srl


#----------------------------------------------------------------------------
#	データ・サブディレクトリへのパス指定
#----------------------------------------------------------------------------
DATABIN			= src/data/
DATASRC			= $(DATABIN)rsc

MSGDATA_DIR		= src/msgdata
MSGDATA_FILENAME	= msg.narc
MSGDATA_FILEPATH	= $(MSGDATA_DIR)/$(MSGDATA_FILENAME)
DATASCENARIO		= $(MSGDATA_DIR)/scenario/
MSGDATA_LANG_PATH	= $(MSGDATA_DIR)/$(LANG_DIR)/$(MSGDATA_FILENAME)


SOUNDDIR		= $(DATABIN)sound/

POKEGRADIR		= src/poketool/pokegra/
TRGRADIR		= src/poketool/trgra/
#バージョンによってパーソナルデータを変更
ifeq	($(PM_VERSION),VERSION_DIAMOND)
PERSONALDIR		= src/poketool/personal/
else
PERSONALDIR		= src/poketool/personal_pearl/
endif
EVOWOTDIR		= src/poketool/personal/
TRAINERDIR		= src/poketool/trainer/
TRMSGDIR		= src/poketool/trmsg/
EFFECTDATADIR	= src/wazaeffect/effectdata/
SAMPLEDATADIR	= src/wazaeffect/pt_debug/
BATTLEGRADIR	= src/battle/graphic/
WAZAEFFDIR		= src/wazaeffect/
WAZASEQDIR		= src/battle/skill/
WAZATBLDIR		= src/poketool/waza/
SCRIPTDIR		= src/fielddata/script/
EVENTDIR		= src/fielddata/eventdata/
ENCOUNTDIR		= src/fielddata/encountdata/
MAPMATRIXDIR	= src/fielddata/mapmatrix/
AREADATADIR		= src/fielddata/areadata/
AREABUILDMDLDIR	= src/fielddata/areadata/area_build_model/
AREAMAPTEXDIR	= src/fielddata/areadata/area_map_tex/
AREAMOVEMDLDIR	= src/fielddata/areadata/area_move_model/
FIELDMAPDIR		= src/fielddata/land_data/
BUILDMODELDIR	= src/fielddata/build_model/
GRAPHICDIR		= src/graphic/
ITEMDATADIR		= src/itemtool/itemdata/
POKEICONGRADIR	= src/poketool/icongra/
POKEFOOTGRADIR	= src/poketool/pokefoot/
WAZAEFFCLACTDIR	= src/wazaeffect/effectclact/
WAZAEFFCLACTRDIR= src/wazaeffect/effectclact/resource/
CONTESTGRADIR	= src/contest/graphic/
CONTESTDATADIR	= src/contest/data/
CLACTUTILDIR	= src/data/clact_util/
PARTICLEDATADIR	= src/particledata/
ZUKANDATADIR 	= src/application/zukanlist/zkn_data/
MMODELDIR		= src/data/mmodel/
WIFIEARTHDIR	= src/application/wifi_earth/
POKEANIMEDIR	= src/pokeanime/
CBDATADIR	 	= src/application/custom_ball/data/
MMLISTDIR		= src/fielddata/mm_list/
DPTITLEDIR 		= src/demo/title/
TRAIDIR 		= src/battle/tr_ai/
ARCDIR			= src/arc/
POKEZUKANDIR	= src/poketool/
POKEANMTBLDIR	= src/poketool/pokeanm/
ZONEDATADIR		= src/fielddata/maptable/
FLDTRADEDIR		= src/fielddata/pokemon_trade/
EGGDATADIR		= src/demo/egg/data/
EGGPTDIR		= src/demo/egg/data/particle/
SHINKAPTDIR		= src/demo/shinka/data/particle/
INTRODIR		= src/demo/intro/
SYOUJYOUDIR		= src/demo/syoujyou/
BTOWERDIR		= src/battle/b_tower/

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/01/22
# 言語ごとに切り換える必要があるリソースファイルを置くところ

ifeq	($(PM_LANG),LANG_ENGLISH)
RESOURCEDIR	= src/resource/eng/
else
ifeq	($(PM_LANG),LANG_FRANCE)
RESOURCEDIR	= src/resource/fra/
else
ifeq	($(PM_LANG),LANG_GERMANY)
RESOURCEDIR	= src/resource/ger/
else
ifeq	($(PM_LANG),LANG_ITALY)
RESOURCEDIR	= src/resource/ita/
else
ifeq	($(PM_LANG),LANG_SPAIN)
RESOURCEDIR	= src/resource/spa/
else
ifeq	($(PM_LANG),LANG_KOREA)
RESOURCEDIR	= src/resource/kor/
endif
endif
endif
endif
endif
endif

# -----------------------------------------------------------------------------

#----------------------------------------------------------------------------
#	コンバート対象になるMayaデータの指定
#----------------------------------------------------------------------------
include	make_g3_files

G3D_NSBMD = $(G3D_IMD:.imd=.nsbmd)
G3D_NSBMT = $(G3D_IMT:.imd=.nsbmt)
#G3D_NSBMTG = $(G3D_GROUND:.imd=.nsbmt)
G3D_NSBTX = $(G3D_TX_IMD:.imd=.nsbtx)
G3D_NSBCA = $(G3D_ICA:.ica=.nsbca)
G3D_NSBVA = $(G3D_IVA:.iva=.nsbva)
G3D_NSBMA = $(G3D_IMA:.ima=.nsbma)
G3D_NSBTP = $(G3D_ITP:.itp=.nsbtp)
G3D_NSBTA = $(G3D_ITA:.ita=.nsbta)

G3D_DATA = $(G3D_NSBMD) $(G3D_NSBTX) $(G3D_NSBCA) $(G3D_NSBVA) $(G3D_NSBMA) $(G3D_NSBTP) $(G3D_NSBTA) $(G3D_NSBMT) #$(G3D_NSBMTG)

G3D_TARGETS	=$(subst rsc/,,$(G3D_DATA))


#----------------------------------------------------------------------------
#	makeサブディレクトリ指定
#
#	SUBDIRSの定義を行っている
#----------------------------------------------------------------------------
include sub_make_files


#----------------------------------------------------------------------------
#	コンパイル対象ソースファイル指定
#
#	SRCSとSRCS_OVERLAYFILESの定義を行っている
#----------------------------------------------------------------------------
include	make_prog_files
include overlay_files

#----------------------------------------------------------------------------
#	ロムに含まれるファイルの指定
#----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/01/22
# 言語ごとに一部リソースを切り換えるように変更
# localize_spec_mark(LANG_ALL) imatake 2007/02/08
# 体験版は一部リソースを切り換えるように変更

FILE_TREE	= $(DATABIN)*.* \
			  $(SOUNDDIR)sound_data.sdat \
			  $(MSGDATA_FILEPATH) \
			  $(DATASCENARIO)*.narc \
			  $(POKEGRADIR)*.narc \
			  $(TRGRADIR)*.narc \
			  $(PERSONALDIR)personal.narc \
			  $(EVOWOTDIR)evo.narc \
			  $(EVOWOTDIR)growtbl.narc \
			  $(EVOWOTDIR)pms.narc \
			  $(EVOWOTDIR)wotbl.narc \
			  $(TRAINERDIR)*.narc \
			  $(TRMSGDIR)*.narc \
			  $(BATTLEGRADIR)*.narc \
			  $(WAZAEFFDIR)we.arc \
			  $(WAZAEFFDIR)we_sub.narc \
			  $(WAZASEQDIR)*.narc \
			  $(WAZAEFFCLACTDIR)*.narc \
			  $(WAZATBLDIR)*.narc \
			  $(SCRIPTDIR)$(SCRIPTFILE) \
			  $(GRAPHICDIR)*.narc \
			  $(ITEMDATADIR)*.narc \
			  $(POKEICONGRADIR)*.narc \
			  $(POKEFOOTGRADIR)pokefoot.narc \
			  $(MMODELDIR)mmodel.narc \
			  $(MMODELDIR)fldeff.narc \
			  $(EFFECTDATADIR)*.narc \
			  $(SAMPLEDATADIR)*.narc \
			  $(EVENTDIR)$(EVENTFILE) \
			  $(ENCOUNTDIR)d_enc_data.narc \
			  $(ENCOUNTDIR)p_enc_data.narc \
			  $(BUILDMODELDIR)*.narc \
			  $(BUILDMODELDIR)*.dat \
			  $(MAPMATRIXDIR)*.narc \
			  $(AREADATADIR)*.narc \
			  $(AREABUILDMDLDIR)*.narc \
			  $(AREAMAPTEXDIR)*.narc \
			  $(AREAMOVEMDLDIR)*.narc \
			  $(FIELDMAPDIR)$(FIELDMAPFILE) \
			  $(CONTESTDATADIR)*.narc \
			  $(PARTICLEDATADIR)*.narc \
			  $(ZUKANDATADIR)zukan_data.narc \
			  $(WIFIEARTHDIR)*.narc \
			  $(CBDATADIR)cb_data.narc \
			  $(EGGDATADIR)egg_data.narc \
			  $(EGGPTDIR)egg_demo_particle.narc \
			  $(MMLISTDIR)move_model_list.narc \
			  $(POKEANIMEDIR)poke_anm.narc \
			  $(TRAIDIR)tr_ai_seq.narc \
			  $(ARCDIR)*.narc \
			  $(ZONEDATADIR)mapname.bin \
			  $(POKEZUKANDIR)pokezukan.narc \
			  $(POKEZUKANDIR)shinzukan.narc \
			  $(POKEANMTBLDIR)pokeanm.narc \
			  $(SHINKAPTDIR)shinka_demo_particle.narc \
			  $(INTRODIR)*.narc \
			  $(SYOUJYOUDIR)syoujyou.narc \
			  $(BTOWERDIR)*.narc \
			  $(ZUKANDATADIR)zukan_enc_diamond.narc \
			  $(ZUKANDATADIR)zukan_enc_pearl.narc \
			  $(RESOURCEDIR)*/*.narc

# -----------------------------------------------------------------------------


#ロムファイルシステムのルートディレクトリ指定
MAKEROM_ROMROOT  = ./src/

MAKEROM_ROMFILES = $(subst src/,,$(FILE_TREE))

#----------------------------------------------------------------------------
#	make cleanで消去するファイルを追加
#----------------------------------------------------------------------------
LDIRT_CLEAN	= $(G3D_TARGETS) $(MSGDATA_FILEPATH) \
			  $(wildcard $(DATABIN)*.nsbmt) $(wildcard $(DATABIN)*.nsbmd) \
			  $(wildcard $(DATABIN)*.nsbta) $(wildcard $(DATABIN)*.nsbtp) \
			  $(wildcard $(DATABIN)*.nsbtx) $(wildcard $(DATABIN)*.nsbma)


#----------------------------------------------------------------------------
#	ツールへのパス指定
#----------------------------------------------------------------------------

ifdef	NITRO_DEBUG
MY_BUILD_DIR		= Deb/$(OUT_DIR)

else
ifdef	NITRO_FINALROM
MY_BUILD_DIR		= Rom/$(OUT_DIR)

else #	NITRO_RELEASE (default)
MY_BUILD_DIR		= Rel/$(OUT_DIR)

endif
endif

OBJDIR			= ./obj/$(MY_BUILD_DIR)
BINDIR			= ./bin/$(MY_BUILD_DIR)
LIBDIR			= ./lib/$(MY_BUILD_DIR)
DEPENDDIR		= ./depend/$(MY_BUILD_DIR)

#----------------------------------------------------------------------------
#	共通変数定義
#----------------------------------------------------------------------------
include commondefs.GF

#----------------------------------------------------------------------------
#	コンパイルルール定義
#----------------------------------------------------------------------------
include modulerules.GF


#----------------------------------------------------------------------------
#	WiFi定義
#----------------------------------------------------------------------------
#include	$(NITRODWC_ROOT)/build/buildtools/commondefs
#include	$(NITRODWC_ROOT)/build/buildtools/modulerules
include	$(NITROVCT_ROOT)/build/buildtools/commondefs
include	$(NITROVCT_ROOT)/build/buildtools/modulerules

################################################################################
#
#
#		コンパイルルール定義
#
#
################################################################################

# -----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2007/02/28
# PG5_UKENGLISH が定義されていたら、ESRB Notice が表示されないように
# localize_spec_mark(LANG_ALL) imatake 2007/04/10
# アーカイブの置き場所を resouce 下に移動
# localize_spec_mark(LANG_KOREA) imatake 2007/09/03
# 韓国語版でも、明示的に指定すれば従来版とのセーブデータ互換を維持するように

do-build: precompile binData msgData msgCopy opdemoCopy zknCopy eooCopy fontCopy savedataCompatible $(TARGETS)

opdemoCopy:
	cp -f $(OPDEMO_NARC_ENG) $(OPDEMO_DIR_ENG)/op_demo.narc

fontCopy:
	cp -f $(RESOURCEDIR)font/shelter/font.narc $(GRAPHICDIR)/font.narc

savedataCompatible:
	touch src/savedata/saveload_system.c

# -----------------------------------------------------------------------------

binData: $(G3D_TARGETS)


#----------------------------------------------------------------------------
# precompile
#----------------------------------------------------------------------------
PRECOMPILE_SRC		 =	include/precompile/precompile.pch
PRECOMPILE_CC_MCH	 =	$(OBJDIR)/precompile_cc.mch
PRECOMPILE_CCFLAGS	:=	$(CCFLAGS)
CCFLAGS			+=	-prefix $(PRECOMPILE_CC_MCH)
ifeq	($(USERNAME),ohno)
CCFLAGS			+=	-msgstyle gcc
endif
#DEPENDDIR		 =	$(OBJDIR)

precompile: $(PRECOMPILE_CC_MCH)

#バージョン定義ファイルが更新されたらプリコンパイルヘッダも更新する
$(PRECOMPILE_CC_MCH):	$(VER_FILE)

-include $(PRECOMPILE_CC_MCH).d
$(PRECOMPILE_CC_MCH):%_cc.mch:
		$(CC) $(PRECOMPILE_CCFLAGS) $(INCLUDES) $(PRECOMPILE_SRC) -MD -precompile $(PRECOMPILE_CC_MCH)
		$(MOVE_SRC_DEPEND)
		$(MV) $(DEPENDDIR)/$(*F).d $@.d
$(OBJS):  $(PRECOMPILE_CC_MCH)

CCFLAGS +=	-thumb
#----------------------------------------------------------------------------
# msgdata
#----------------------------------------------------------------------------
MSG_NAIX_COPYSCRIPT	= convert/message/naixcopy.pl
MSG_CONVERTDATA_DIR	= convert/message/data/$(LANG_DIR)

MSG_HEADERFILE_DIR	= include/msgdata/

msgCopy:
	@cp $(MSGDATA_LANG_PATH) $(MSGDATA_DIR)

zknCopy:
	@cp $(ZUKANDATADIR)$(LANG_DIR)/zukan_data.narc $(ZUKANDATADIR)

eooCopy:
	@cp $(RESOURCEDIR)downloader/eoo.dat $(DATABIN)

msgData: $(MSGDATA_LANG_PATH)

$(MSGDATA_LANG_PATH): $(wildcard $(MSG_CONVERTDATA_DIR)/*.dat)
	nnsarc -c -l -n -i $(MSGDATA_FILENAME) $(MSG_CONVERTDATA_DIR)/*.dat
	$(MV) $(MSGDATA_FILENAME) $(MSGDATA_LANG_PATH)
	perl $(MSG_NAIX_COPYSCRIPT)  msg.naix $(MSG_HEADERFILE_DIR)msg.naix
	-$(RM) msg.naix

#----------------------------------------------------------------------------
#	makefileがインクルードするファイルが更新されたらmakelcfが動作するようにした
#----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2006/09/08
# makelcf動作の条件に default.lsf の更新を追加
$(MAKEFILE):	commondefs.GF modulerules.GF make_prog_files make_g3_files main.lsf overlay_files overlaytool.rb default.lsf
	-$(RM) $(BINDIR)/$(LCFILE_SPEC:.lsf=.*)
	ruby overlaytool.rb
	touch $(MAKEFILE)

#----------------------------------------------------------------------------
#	ソースの類が１個でもbuilddate.cより新しい場合builddate.cをtouch&コンパイル
#----------------------------------------------------------------------------
# localize_spec_mark(LANG_ALL) imatake 2006/09/08
# 拡張メモリに配置するソースの更新も反映するように変更
./src/system/builddate.c: $(SRCS) $(SRCS_OVERLAY) $(SRCS_AUTOLOAD)
	touch ./src/system/builddate.c


#----------------------------------------------------------------------------
#	セルアクターヘッダー内のアーカイブファイルIDと
#	arc_tool.dat内のアーカイブファイルIDが統一されているかをチェックする
#	perlを実行する
#----------------------------------------------------------------------------
#clact_arcfile_check:
#	perl src/data/clact_util/clact_check.pl

#----------------------------------------------------------------------------
#	強制コンパイル
#
#	builddate.cをtouchしてコンパイルしている
#----------------------------------------------------------------------------
force:
	touch ./src/system/builddate.c
	$(MAKE)

#----------------------------------------------------------------------------
#	ソースのみのリコンパイル
#----------------------------------------------------------------------------
source:
	-$(RM) $(GDIRT_CLEAN)
	-$(RM) $(DEPENDDIR)/*.d
	$(MAKE)

#----------------------------------------------------------------------------
#	このMakefile管轄下のモデリングデータリコンパイル
#----------------------------------------------------------------------------
model:
	-$(RM)	$(G3D_TARGETS) \
		  	$(wildcard $(DATABIN)*.nsbmt) $(wildcard $(DATABIN)*.nsbmd) \
			$(wildcard $(DATABIN)*.nsbta) $(wildcard $(DATABIN)*.nsbtp) \
			$(wildcard $(DATABIN)*.nsbtx) $(wildcard $(DATABIN)*.nsbma)
	-$(RM)	$(wildcard $(FIELDMAPDIR)/land_nsbmt/*.nsbmt) \
			$(FIELDMAPDIR)land_data.narc
	$(MAKE) model -C $(BUILDMODELDIR)

#----------------------------------------------------------------------------
#	地形データのモデリングデータリコンパイル
#----------------------------------------------------------------------------
land:
	-$(RM)	$(wildcard $(FIELDMAPDIR)/land_nsbmt/*.nsbmt) \
			$(FIELDMAPDIR)land_data.narc
	$(MAKE) imdconv -C $(FIELDMAPDIR)
	$(MAKE) force

landall:
	-$(RM)	$(wildcard $(FIELDMAPDIR)/land_nsbmt/*.nsbmt) \
			$(FIELDMAPDIR)land_data.narc
	-$(MAKE) imdconv -C $(FIELDMAPDIR)
	-$(MAKE) ctex

#----------------------------------------------------------------------------
#	Buildモデルのみのリコンパイル
#----------------------------------------------------------------------------
#src/fielddata/build_model/make all
bmall:
	$(MAKE) -C $(BUILDMODELDIR) clean all
	$(MAKE) force

#src/fielddata/build_model/make model 
bimd:
	$(MAKE) model -C $(BUILDMODELDIR)
	$(MAKE) force

#src/fielddata/build_model/make 
bm:
	$(MAKE) -C $(BUILDMODELDIR)
	$(MAKE) force

#src/fielddata/areadata/area_build_model/make all
abmall:
	$(MAKE) -C $(AREABUILDMDLDIR) clean all
	$(MAKE) force

#src/fielddata/areadata/area_build_model/make
abm:
	$(MAKE) -C $(AREABUILDMDLDIR)
	$(MAKE) force

#src/data/clact_util/make
clact:
	$(MAKE) -C $(CLACTUTILDIR)
	$(MAKE) force

#src/data/clact_util/make clean
clact_clean:
	$(MAKE) -C $(CLACTUTILDIR) clean

#----------------------------------------------------------------------------
# 	地形チップテクスチャリコンパイル	
#----------------------------------------------------------------------------
ctex:
	$(MAKE) -C $(AREAMAPTEXDIR) clean all
	$(MAKE) force

#----------------------------------------------------------------------------
#	バイナリ比較
#----------------------------------------------------------------------------
diff:
	cp ./bin/ARM9-TS/Release/main.srl ./bin/ARM9-TS/Release/old.srl
	$(MAKE) do-build
	$(MAKE) onlydiff

onlydiff:
	fc /b .\\bin\\ARM9-TS\\Release\\main.srl .\\bin\\ARM9-TS\\Release\\old.srl

#一時コマンド04/04 iwasawa 後で消します
del_land_list:
	$(RM) $(FIELDMAPDIR)land_list
