#! make -f

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

SRCS			 = main.c child.c peripheral.c screen.c gui.c

SRCDIR			 = ./src

LINCLUDES		 = ../mb_loader/include
LINCLUDES		+= $(NITROSDK_ROOT)/build/libraries/mb/include

LLIBRARY_DIRS		 = ../mb_loader/lib/$(NITRO_LIBTYPE)

LOADER_LIB		 = libmbloader$(NITRO_LIBSUFFIX).a 

LLIBRARIES		 = $(LOADER_LIB)

LLIBRARY_DIRS		+= ./mylib/$(NITRO_LIBTYPE)

TARGET_BIN		 = main.nef

CRT0_O			 = crt0.o

LANG_DATA		= resource/$(PM_LANG)/font_system.gly resource/$(PM_LANG)/font_system.wid

-include ../version

# localize_spec_mark(LANG_ALL) yamamoto 2007/02/09
ifeq	($(PM_LANG),LANG_ENGLISH)
MACRO_FLAGS += -DGGID=0x00400286		# DP-PBR通信用(multibootモドキ用)GGID
else
ifeq	($(PM_LANG),LANG_FRANCE)
MACRO_FLAGS += -DGGID=0x008000EC		# DP-PBR通信用(multibootモドキ用)GGID
else
ifeq	($(PM_LANG),LANG_GERMANY)
MACRO_FLAGS += -DGGID=0x008000ED		# DP-PBR通信用(multibootモドキ用)GGID
else
ifeq	($(PM_LANG),LANG_ITALY)
MACRO_FLAGS += -DGGID=0x008000EE		# DP-PBR通信用(multibootモドキ用)GGID
else
ifeq	($(PM_LANG),LANG_SPAIN)
MACRO_FLAGS += -DGGID=0x008000EF		# DP-PBR通信用(multibootモドキ用)GGID
else
ifeq	($(PM_LANG),LANG_KOREA)
MACRO_FLAGS += -DGGID=0x00C00017		# DP-PBR通信用(multibootモドキ用)GGID
endif
endif
endif
endif
endif
endif
#MACRO_FLAGS += -DCOMPAT_PBRJP_LIDCOMCLOSE=1	# フタを閉じられた時に通信を切断する
#MACRO_FLAGS += -DCOMPAT_PBRJP_STRICTCHECK=1	# ROMコードがポケモンDP(ADAJ,APAJ)かどうかをチェックする (hack.hで行われている)
MACRO_FLAGS	+=	-DPM_LANG=$(PM_LANG)
export MACRO_FLAGS




# [for pokemon_dp download] Cryptoライブラリ追加。
NITRO_LIBS		 = libfx$(NITRO_LIBSUFFIX).a		\
			   libgx$(NITRO_LIBSUFFIX).a 		\
			   libos$(TS_VERSION)$(NITRO_LIBSUFFIX).a \
			   libmi$(NITRO_LIBSUFFIX).a		\
			   libsnd$(NITRO_LIBSUFFIX).a		\
			   libpxi$(NITRO_LIBSUFFIX).a		\
			   libext$(NITRO_LIBSUFFIX).a		\
			   libfs$(NITRO_LIBSUFFIX).a		\
			   libdgt$(NITRO_LIBSUFFIX).a		\
			   libcp$(NITRO_LIBSUFFIX).a		\
			   libspi$(TS_VERSION)$(NITRO_LIBSUFFIX).a \
			   librtc$(NITRO_LIBSUFFIX).a		\
			   libprc$(NITRO_LIBSUFFIX).a		\
			   libcard$(NITRO_LIBSUFFIX).a		\
			   libwm$(NITRO_LIBSUFFIX).a		\
			   libwbt$(NITRO_LIBSUFFIX).a		\
			   libmb$(NITRO_LIBSUFFIX).a		\
			   libctrdg$(NITRO_LIBSUFFIX).a		\
			   libmysyscall.a			\
			   libmath$(NITRO_LIBSUFFIX).a			\
			   libcrypto$(NITRO_LIBSUFFIX).a		\
			   $(CRT0_O)

ifdef		NITRO_PROFILE_TYPE
NITRO_LIBS		+= libos.$(NITRO_PROFILE_TYPE)$(NITRO_LIBSUFFIX).a
endif

include	$(NITROSDK_ROOT)/build/buildtools/commondefs

BINTOELF	=	$(CW_BINDIR)/bintoelf.exe

EXT_OBJS	=	$(OBJDIR)/winframe_system_bg.o \
				$(OBJDIR)/winframe_system_pal.o \
				$(OBJDIR)/winframe_talk_bg.o $(OBJDIR)/winframe_talk_pal.o \
				$(OBJDIR)/win_cursor1_bg.o \
				$(OBJDIR)/font_system_gly.o $(OBJDIR)/font_system_wid.o \
				$(OBJDIR)/wireless_strength_level_w_bg.o \
				$(OBJDIR)/wireless_strength_level_w_pal.o \

#----------------------------------------------------------------------------
# makelcf 設定
#

LCFILE_SPEC		 = mb_child.lsf
LCFILE_TEMPLATE		 = my.lcf.template
MAKELCF_FLAGS		+= -DLOADER_LIB='$(LOADER_LIB)'


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

do-build:	copy-resource $(TARGETS)

copy-resource:
	@cp $(LANG_DATA) data

include	$(NITROSDK_ROOT)/build/buildtools/modulerules

$(OBJDIR)/winframe_system_bg.o: data/winframe_system.bg
	$(BINTOELF) $< -output $@

$(OBJDIR)/winframe_system_pal.o: data/winframe_system.pal
	$(BINTOELF) $< -output $@

$(OBJDIR)/winframe_talk_bg.o: data/winframe_talk.bg
	$(BINTOELF) $< -output $@

$(OBJDIR)/winframe_talk_pal.o: data/winframe_talk.pal
	$(BINTOELF) $< -output $@

$(OBJDIR)/win_cursor1_bg.o: data/win_cursor1.bg
	$(BINTOELF) $< -output $@

$(OBJDIR)/font_system_gly.o: data/font_system.gly
	$(BINTOELF) $< -output $@

$(OBJDIR)/font_system_wid.o: data/font_system.wid
	$(BINTOELF) $< -output $@

$(OBJDIR)/wireless_strength_level_w_bg.o: data/wireless_strength_level_w.bg
	$(BINTOELF) $< -output $@

$(OBJDIR)/wireless_strength_level_w_pal.o: data/wireless_strength_level_w.pal
	$(BINTOELF) $< -output $@


#===== End of Makefile =====
