#!/usr/bin/env omake
#----------------------------------------------------------------------------
#    A[JCuf[^
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
#      [U[`
#----------------------------------------------------------------------------
.PHONY : copyfile

USERS = nagihashi_toru morimoto

#----------------------------------------------------------------------------
#      ^[Qbgt@C
#----------------------------------------------------------------------------
target = pokemon_memory
xls    = pokemon_memory_data.xlsx
defcsv  = def.csv
maincsv = main.csv
mstxt   = ../../prog/include/message/msg_pokemon_memory.h

#----------------------------------------------------------------------------
#      Rs[tH_
#----------------------------------------------------------------------------
ARC_DIR = $(getenv PROJECT_ROOT)/arc
HEADER_DIR = $(getenv PROGRAMDIR)/src/poke_tool/

#----------------------------------------------------------------------------
#      macro
#----------------------------------------------------------------------------
include $(getenv PROJECT_ROOT)/resource/macro_define
include $(getenv GFL_TOOL_DIR)/lytsys/maketool

#----------------------------------------------------------------------------
#      c[
#----------------------------------------------------------------------------
EXCEL_CONVERTER       = ruby $(getenv GFL_TOOL_DIR)/tabout/tab_out_direct_sheet.rb
POKEMEMORY_CONVERTER  = ruby pokemon_memory_converter.rb


#----------------------------------------------------------------------------
#      rh[
#----------------------------------------------------------------------------

.PHONY: 

build: $(HEADER_DIR)/$(target).h $(HEADER_DIR)/$(target).cdat

$(HEADER_DIR)/$(target).h: $(target).h
  cp $(target).h $(HEADER_DIR)

$(HEADER_DIR)/$(target).cdat: $(target).cdat
  cp $(target).cdat $(HEADER_DIR)
  
if $(equal $(CONVERTUSER), true)
  $(target).cdat $(target).h: $(xls)
     $(EXCEL_CONVERTER) -s -n 0 $(xls) > $(maincsv)
     $(EXCEL_CONVERTER) -s -n 1 $(xls) > $(defcsv)
     $(POKEMEMORY_CONVERTER) $(maincsv) $(defcsv) $(mstxt) $(target)
 
  
clean:
  if $(equal $(CONVERTUSER), true)
    rm -f *.csv
    rm -f *.cdat
    rm -f *.h


DefineDefaultRules()

