#----------------------------------------------------------------------------
#
#    g3d\[XRo[g OMakefile
#   
#----------------------------------------------------------------------------

include ../area_common.def

#----------------------------------------------------------------------------
#    [U[`
#        CONVERT̓etrueɂ[U[Lq
#        jtomoya_takahashi hoge hoge2
#----------------------------------------------------------------------------
USERS[] =takahashi_tomoya kawada_koji ishiguro_masateru fujiwara_maiko tanoue_reiko lee_hyunjung suganuma_teruki




#----------------------------------------------------------------------------
#    ^[Qbgt@C
#        Ƀ^[Qbgt@CLq@
#        jlyt_test_res
#----------------------------------------------------------------------------
NARC_FILE=field_camera_area

OUTPUTDIR = output
RESDIR = res


#----------------------------------------------------------------------------
# Ro[gΏ
#----------------------------------------------------------------------------
XLS_OBJ = $(basename $(glob res/*.xls))


#----------------------------------------------------------------------------
#			c[
#----------------------------------------------------------------------------
XLS2TAB = $(getenv GFL_TOOL_DIR)/exceltool/xls2xml/tab_out.rb
CONVERTER = camera_area.rb

#----------------------------------------------------------------------------
# Excel->Text
#----------------------------------------------------------------------------
GetXls2Tab(xls) =
   
  OFILES[] =
  
  foreach( ifile, $(xls) )
    ifile = $(RESDIR)/$(ifile)
    OFILE = $(replacesuffixes .xls, .txt, $(ifile))
    OFILES += $(OFILE)
    $(OFILE):$(ifile)
      ruby $(XLS2TAB) $(ifile) > $(OFILE)
    
    export OFILES
    
  return $(OFILES)



#----------------------------------------------------------------------------
# txt -> bin    oCi
#----------------------------------------------------------------------------
Convert(texts) = 
  OFILES[] = 

  foreach( ifile, $(texts) )
    OFILE = $(OUTPUTDIR)/$(replacesuffixes .txt, .bin, $(basename $(ifile)))
    OFILES += $(OFILE)
    $(OFILE) : $(ifile)
      ruby $(CONVERTER) $(ifile) $(OFILE)

    export OFILES

  return $(OFILES)

#----------------------------------------------------------------------------
#    Rs[tH_
#        ɃRs[tH_@
#        j$(getenv PROJECT_ROOT)/skel/romfiles/
#----------------------------------------------------------------------------
# ResourceFiles.omɋLqς

NARC_DIR =$(getenv PROJECT_ROOT)/arc/
NAIX_DIR =$(getenv PROJECT_ROOT)/arc/


#----------------------------------------------------------------------------
#    macro
#        ̃}NǂݍނƂŁACONVERTUSERȂǂ`B
#----------------------------------------------------------------------------
include $(getenv PROJECT_ROOT)/resource/macro_define


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

build:$(NAIX_DIR)$(NARC_FILE).gaix $(NARC_DIR)$(NARC_FILE).garc

if $(equal $(CONVERTUSER), true)
  $(NARC_FILE).gaix:$(NARC_FILE).garc
    echo
  
  
  $(NARC_FILE).garc:$(Convert $(GetXls2Tab $(XLS_OBJ)))
    $(GFARC) $(NARC_FILE).garc $(OUTPUTDIR)


$(NAIX_DIR)$(NARC_FILE).gaix: $(NARC_FILE).gaix
  cp $(NARC_FILE).gaix $(NAIX_DIR)

$(NARC_DIR)$(NARC_FILE).garc: $(NARC_FILE).garc
  cp $(NARC_FILE).garc $(NARC_DIR)



clean:
  rm -f $(NARC_DIR)$(NARC_FILE).garc
  rm -f $(NAIX_DIR)$(NARC_FILE).gaix

  #ƁAUSER삵Ȃ
  if $(equal $(CONVERTUSER), true)
    rm -f $(OUTPUTDIR)/*.bin
    rm -f $(NARC_FILE).garc
    rm -f $(NARC_FILE).gaix


DefineDefaultRules()


