#---------------------------------------------------------------------------- # Project: Horizon # File: CTR.commondefs.func.om # # Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. # # These coded instructions, statements, and computer programs contain # proprietary information of Nintendo of America Inc. and/or Nintendo # Company Ltd., and are protected by Federal copyright law. 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. # # $Rev: 48432 $ #---------------------------------------------------------------------------- #---------------------------------------------------------------------------- # Function definitions #---------------------------------------------------------------------------- public.GetBannerFile(config) = private.banner = $(config.getDefaultBannerFile) if $(defined CTR_BANNER_SPEC) private.base = $(removesuffix $(basename $(CTR_BANNER_SPEC))) return $(addprefix $(config.getObjectDirectory)$(DIRSEP), $(addsuffixes $(EXT_BANNER), $(base))) else if $(defined CTR_BANNER) return $(CTR_BANNER) elseif $(or $(and $(defined CTR_NO_BANNER_ICON), $(equal $(CTR_NO_BANNER_ICON), true)), \ $(and $(defined CTR_NO_BANNER), $(equal $(CTR_NO_BANNER), true)) ) return $(EMPTY) return $(banner) public.GetIconFile(config) = private.icon = $(config.getDefaultIconFile) if $(defined CTR_BANNER_SPEC) private.base = $(removesuffix $(basename $(CTR_BANNER_SPEC))) return $(addprefix $(config.getObjectDirectory)$(DIRSEP), $(addsuffixes $(EXT_ICON), $(base))) else if $(defined CTR_ICON) return $(CTR_ICON) elseif $(and $(defined CTR_NO_BANNER_ICON), $(equal $(CTR_NO_BANNER_ICON), true)) return $(EMPTY) return $(icon) public.GetMakeromOptions(config)= private.romfs_root = $(if $(defined ROMFS_ROOT),$`(ROMFS_ROOT),$(EMPTY)) private.title = $(if $(defined TITLE),$`(TITLE),CtrApp) private.flags[] = -DROMFS_ROOT=$(romfs_root) -DTITLE=$(title) BannerFile = $(GetBannerFile $(config)) IconFile = $(GetIconFile $(config)) if $(not $(equal $(BannerFile.length), 0)) flags += -banner $(BannerFile) export flags if $(not $(equal $(IconFile.length), 0)) flags += -icon $(IconFile) export flags return $(flags) global.FilterOutOptionPair(key, list) = if $(lt $(length $(list)),2) return $(list) if $(equal $(key),$(nth 0,$(list))) return $(FilterOutOptionPair $(key),$(nth-tl 2,$(list))) return $(nth 0,$(list)) $(FilterOutOptionPair $(key),$(nth-tl 1,$(list))) #------------------------------------------------------- # AddRuleToMakeCci # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCci(cci, elf, flags, depends) = $(cci): $(makeDirectory $(dirname $(cci))) $(cci): $(elf) $(depends) $(MAKEROM) build-romfs :value: $(getMtimeIfLarge $(elf) $(depends)) $(MAKEROM) -o $@ $(elf) $(flags) -f card return $(cci) #------------------------------------------------------- # AddRuleToMakeCclE # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCclE(ccl_e, elf, r, flags, depends) = $(ccl_e): $(makeDirectory $(dirname $(ccl_e))) $(ccl_e): $(elf) $(r) $(depends) $(MAKEROM) build-romfs :value: $(getMtimeIfLarge $(elf) $(r) $(depends)) $(MAKEROM) -o $@ $< $(flags) -lr $(r) -f le -m 0x01000000 return $(ccl_e) #------------------------------------------------------- # AddRuleToMakeCclR # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCclR(ccl_r, flags, depends) = $(ccl_r): $(makeDirectory $(dirname $(ccl_r))) $(ccl_r): $(depends) $(MAKEROM) build-romfs :value: $(getMtimeIfLarge $(depends)) $(MAKEROM) -o $@ $(flags) -f lr return $(ccl_r) #------------------------------------------------------- # AddRuleToMakeCcl # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCcl(ccl, e, r) = $(ccl): $(makeDirectory $(dirname $(ccl))) $(ccl): $(e) $(r) $(MAKEROM) build-romfs :value: $(getMtimeIfLarge $(e) $(r)) $(MAKEROM) -o $@ -le $(e) -lr $(r) -f list return $(ccl) #------------------------------------------------------- # AddRuleToMakeCxi # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCxi(cxi, elf, flags, depends) = $(cxi): $(makeDirectory $(dirname $(cxi))) $(cxi): $(elf) $(depends) $(MAKEROM) build-romfs :value: $(getMtimeIfLarge $(elf) $(depends)) $(MAKEROM) -o $@ $< $(flags) return $(cxi) #------------------------------------------------------- # AddRuleToMakeCia # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCia(cia, flags, depends) = $(cia): $(makeDirectory $(dirname $(cia))) $(cia): $(depends) $(MAKECIA) :value: $(getMtimeIfLarge $(depends)) $(MAKECIA) -o $@ $(flags) return $(cia) #------------------------------------------------------- # AddRuleToMakeCfa # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeCfa(cfa, srcdir, flags, depends) = $(cfa): $(makeDirectory $(dirname $(cfa))) $(cfa): $(srcdir) $(depends) $(MAKEROM) :value: $(getMtimeIfLarge $(depends)) $(MAKEROM) -o $@ -DROMFS_ROOT=$(srcdir) $(flags) -f data return $(cfa) #------------------------------------------------------- # AddRuleToMakeBanner # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeBanner(banner, icon, bsf) = $(banner): $(makeDirectory $(dirname $(banner))) $(icon): $(makeDirectory $(dirname $(icon))) $(banner) $(icon): $(bsf) $(MAKEBANNER) $(MAKEBANNER) $< $(banner) $(icon) return $(banner) $(icon) #------------------------------------------------------- # AddRuleToMakeIcon # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- AddRuleToMakeIcon(icon, bsf) = $(icon): $(makeDirectory $(dirname $(icon))) $(icon): $(bsf) $(MAKEBANNER) $(MAKEBANNER) -d -nobnr $(file $<) $(absname $(icon)) return $(icon) AddRuleToMakeCfaFromCias(cfa, flags, depends) = $(cfa): $(makeDirectory $(dirname $(cfa))) $(cfa): $(depends) $(MAKECIAARCHIVE) :value: $(getMtimeIfLarge $(depends)) $(MAKECIAARCHIVE) -o $@ $(flags) return $(cfa) #------------------------------------------------------- # MakeCci # # Overview # Create .cci from ELF # Return the .cci path # # Referenced global variables # None. #------------------------------------------------------- MakeCci(config, name, elf, flags, cci_depends) = private.cci = $(config.getBinaryPath $(name), $(EXT_CCI)) return $(AddRuleToMakeCci $(cci),$(elf),$(flags), $(cci_depends)) #------------------------------------------------------- # MakeCclE # # Overview # Create the E portion of .ccl # Return the path to the E portion of .ccl # # Referenced global variables # None. #------------------------------------------------------- MakeCclE(config, name, elf, r, flags, depends) = private.e = $(config.getBinaryPath $(name), $(EXT_CCL_E)) return $(AddRuleToMakeCclE $(e),$(elf),$(r),$(flags),$(depends)) #------------------------------------------------------- # MakeCclR # # Overview # Create the R portion of .ccl # Return the path to the R portion of .ccl # # Referenced global variables # None. #------------------------------------------------------- MakeCclR(config, name, flags, cci_depends) = private.r = $(config.getBinaryPath $(name), $(EXT_CCL_R)) return $(AddRuleToMakeCclR $(r),$(flags),$(cci_depends)) #------------------------------------------------------- # MakeCcl # # Overview # Create .ccl # Return the .ccl path # # Referenced global variables # None. #------------------------------------------------------- MakeCcl(config, name, e, r) = private.ccl = $(config.getBinaryPath $(name), $(EXT_CCL)) return $(AddRuleToMakeCcl $(ccl),$(e),$(r)) #------------------------------------------------------- # MakeCxi # # Overview # Create .cxi from ELF # Return the .cxi path # # Referenced global variables # None. #------------------------------------------------------- MakeCxi(config, name, elf, flags, cxi_depends) = private.cxi = $(config.getBinaryPath $(name), $(EXT_CXI)) return $(AddRuleToMakeCxi $(cxi),$(elf),$(flags), $(cxi_depends)) #------------------------------------------------------- # MakeCia # # Overview # Create .cia from .cxi # Return the .cia path # # Referenced global variables # None. #------------------------------------------------------- MakeCia(config, name, flags, depends) = private.cia = $(config.getBinaryPath $(name), $(EXT_CIA)) return $(AddRuleToMakeCia $(cia), $(flags), $(depends)) #------------------------------------------------------- # MakeCfa # # Overview # Create .cfa from the directory # Return the .cfa path # # Referenced global variables # None. #------------------------------------------------------- MakeCfa(config, name, srcdir, flags, depends) = private.cfa = $(config.getBinaryPath $(name), $(EXT_CFA)) return $(AddRuleToMakeCfa $(cfa), $(srcdir), $(flags), $(depends)) #------------------------------------------------------- # MakeBanner # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- MakeBanner(config, rsf) = private.banner = $(GetBannerFile $(config)) private.icon = $(GetIconFile $(config)) return $(AddRuleToMakeBanner $(banner),$(icon),$(bsf)) #------------------------------------------------------- # MakeIcon # # Overview # | # # Referenced global variables # None. #------------------------------------------------------- MakeIcon(config, bsf) = private.base = $(removesuffix $(bsf)) private.icon = $(addprefix $(config.getObjectDirectory)$(DIRSEP), $(addsuffixes $(EXT_ICON), $(base))) return $(AddRuleToMakeIcon $(icon),$(bsf)) #------------------------------------------------------- # BuildCci # # Overview # Create .cci # Return the .cci path # # Referenced global variables # None. #------------------------------------------------------- BuildCci(config, name, files, cci_flags, cci_depends) = private.elf = $(ExecutableElf $(config), $(name), $(files)) private.cci = $(MakeCci $(config), $(name), $(elf), $(cci_flags), $(cci_depends)) return $(cci) #------------------------------------------------------- # BuildCcl # # Overview # Create .ccl # Return the .ccl path # # Referenced global variables # None. #------------------------------------------------------- BuildCcl(config, name, files, cci_flags, cci_depends, r_depends) = private.elf = $(ExecutableElf $(config), $(name), $(files)) private.r = $(MakeCclR $(config), $(name), $(cci_flags), $(r_depends) $(cci_depends)) private.e = $(MakeCclE $(config), $(name), $(elf), $(r), $(cci_flags), $(cci_depends)) private.ccl = $(MakeCcl $(config), $(name), $(e), $(r)) return $(ccl) #------------------------------------------------------- # BuildCia # # Overview # Create .cia # Return the .cia path # # Referenced global variables # None. #------------------------------------------------------- BuildCia(config, name, files, cxi_flags, cia_flags, cxi_depends, cia_depends) = if $(files) private.elf = $(ExecutableElf $(config), $(name), $(files)) private.cxi = $(MakeCxi $(config), $(name), $(elf), $(cxi_flags), $(cxi_depends)) cia_flags = -i $(cxi) $(cia_flags) cia_depends += $(cxi) export cia_flags export cia_depends return $(MakeCia $(config), $(name), $(cia_flags), $(cia_depends)) MakeCfaFromCias(config, name, cia_list, rsf) = private.workdir = $(makeDirectory $(makePath $(config.getObjectDirectory) $(name))) private.cfa = $(makePath $(config.getObjectDirectory) $(name)$(EXT_CFA)) private.flags = -cia $(cia_list) -rsf $(rsf) --romfs-root $(workdir) private.depends = $(cia_list) $(rsf) $(workdir) return $(AddRuleToMakeCfaFromCias $(cfa), $(flags), $(depends)) MakeChildCfa(config, cia_list) = private.rsf = $(makePath $(ROOT_RESOURCES) specfiles Child.rsf) return $(MakeCfaFromCias $(config), Child, $(cia_list), $(rsf)) MakeManualCfa(config, manual_dir, flags, depends) = private.rsf = $(makePath $(ROOT_RESOURCES) specfiles Manual.rsf) flags += -rsf $(rsf) return $(MakeCfa $(config), Manual, $(manual_dir), $(flags), $(rsf) $(depends)) #------------------------------------------------------- # DataContent # # Overview # Create data content combined .cxi and .cfa files # Return the .cia path # # Referenced global variables # None. #------------------------------------------------------- DataContent(config, name, contents, flags) = flags += $(mapToArray $(contents),$(fun k,v,$(array -i,$(v):$(k)))) private.depends = $(mapToArray $(contents),$(fun k,v,$(v))) return $(MakeCia $(config), $(name), $(flags), $(depends)) #------------------------------------------------------- # InstallProgram # # Overview # | # # Referenced global variables # BUILDTYPES #------------------------------------------------------- InstallProgram(config, install_dir, files) = if $(not $(files)) return $(EMPTY) if $(or $(and $(config.isSdkTool),\ $(equal $(filter full,$(BUILDTYPES)),full)),\ $(and $(not $(config.isSdkTool)),\ $(not $(equal $(install_dir), $(dirname $(nth 0, $(files))))))) private.ofiles = foreach(outfile, $(files)) dst = $(install_dir)/$(basename $(outfile)) value $(AddRuleToInstall $(dst),$(outfile)) return $(ofiles) return $(EMPTY) ProgramCard(config, name, files, flags, depends) = return $(BuildCci $(config),$(name),$(files),$(flags.find cci),$(depends.find cci)) ProgramList(config, name, files, flags, depends) = return $(BuildCcl $(config),$(name),$(files),$(flags.find cci),$(depends.find cci),$(depends.find rom_fs)) ProgramImport(config, name, files, flags, depends) = return $(BuildCia $(config),$(name),$(files), \ $(flags.find cxi), $(flags.find cia), \ $(depends.find cxi), $(depends.find cia) ) ProgramPatch(config, name, files, flags, depends) = private.cxi_flags = $(flags.find cxi) private.cia_flags = $(flags.find cia) private.cxi_depends = $(depends.find cxi) private.cia_depends = $(depends.find cia) private.cnt_depends = $(depends.find cnt) cxi_flags = $(FilterOutOptionPair -banner,$(cxi_flags)) cia_flags = $(FilterOutOptionPair -i,$(cia_flags)) cxi_depends = $(filter-out $(GetBannerFile $(config)),$(cxi_depends)) cia_depends = $(filter-out $(cnt_depends),$(cia_depends)) return $(BuildCia $(config),$(name),$(files), \ $(cxi_flags),$(cia_flags),$(cxi_depends),$(cia_depends)) #------------------------------------------------------- # Program # # Overview # Create CTR execution file # # Referenced global variables # BUILD_APPLICATION, LDSCRIPT, CRT_0_O, # ROMFS_DEPENDENCIES, ROMFS_ROOT, MAKEROMFLAGS, # DESCRIPTOR, ROM_SPEC_FILE, CTR_APPTYPE, # PROGRAM_BUILDER_MAP, MANUAL_DIR, CHILD_APPS, # MANUAL_DEPENDENCIES #------------------------------------------------------- Program(config, name, files) = global.BUILD_APPLICATION = true private.contents = $(Map) if $(not $(defined LDSCRIPT)) LDSCRIPT = $(config.getDefaultLdscriptPath) export if $(not $(defined CRT_0_O)) CRT_0_O = crt0.o export if $(not $(defined ROMFS_DEPENDENCIES)) if $(defined ROMFS_ROOT) ROMFS_DEPENDENCIES = $(ls -R, $(dir $(ROMFS_ROOT))) export else ROMFS_DEPENDENCIES = export export if $(not $(defined MANUAL_DEPENDENCIES)) if $(defined MANUAL_DIR) MANUAL_DEPENDENCIES = $(ls -R, $(dir $(MANUAL_DIR))) export else MANUAL_DEPENDENCIES = export export # For manual if $(defined MANUAL_DIR) private.cfa = $(MakeManualCfa $(config), $(MANUAL_DIR), $(MAKEROMFLAGS), $(MANUAL_DEPENDENCIES)) contents = $(contents.add 1,$(cfa)) export contents # For child if $(defined CHILD_APPS) private.cfa = $(MakeChildCfa $(config), $(CHILD_APPS)) contents = $(contents.add 2,$(cfa)) export contents private.desc = $(if $(defined DESCRIPTOR),$`(DESCRIPTOR),$(config.getDefaultDescriptorPath)) private.cxi_flags = $(MAKEROMFLAGS) private.cci_flags = $(EMPTY_ARRAY) private.cia_flags = $(MAKECIAFLAGS) private.rom_fs_depends = $(ROMFS_DEPENDENCIES) private.cxi_depends = $(desc) $(ROM_SPEC_FILE) $(GetBannerFile $(config)) $(GetIconFile $(config)) private.cci_depends = $(EMPTY_ARRAY) private.cia_depends = $(EMPTY_ARRAY) private.cnt_depends = $(EMPTY_ARRAY) cxi_flags += -desc $(desc) -rsf $(ROM_SPEC_FILE) cxi_flags += $(GetMakeromOptions $(config)) cci_flags += $(mapToArray $(contents),$(fun k,v,-content $(v):$(k))) cia_flags += $(mapToArray $(contents),$(fun k,v,-i $(v):$(k))) cnt_depends += $(mapToArray $(contents),$(fun k,v,$(v))) private.flags = $(Map) private.depends = $(Map) flags = $(flags.add cxi,$(cxi_flags)) flags = $(flags.add cci,$(cxi_flags) $(cci_flags)) flags = $(flags.add cia,$(cia_flags)) depends = $(depends.add rom_fs,$(rom_fs_depends)) depends = $(depends.add cxi,$(rom_fs_depends) $(cxi_depends)) depends = $(depends.add cci,$(rom_fs_depends) $(cxi_depends) $(cci_depends) $(cnt_depends)) depends = $(depends.add cia,$(cia_depends) $(cnt_depends)) depends = $(depends.add cnt,$(cnt_depends)) private.app_type = if $(equal $(CTR_APPTYPE),$(APPTYPE_BOTH)) value $(APPTYPE_CARD) $(APPTYPE_NAND) else value $(CTR_APPTYPE) private.target_files = foreach (type, $(app_type)) private.builder = $(PROGRAM_BUILDER_MAP.find $(type)) if $(builder) value $(apply $(builder), $(config), $(name), $(files), $(flags), $(depends)) else eprintln($"Build Error: Unknown APPTYPE:" '$(type)') exit(1) target_files = $(stripEmpty $(target_files)) # If the tree is referenced externally, determine whether to install private.install_dir = $(config.getImageDirectory true) private.install_targets = $(InstallProgram $(config),$(install_dir),$(target_files)) return $(target_files) $(install_targets) #------------------------------------------------------- # Banner # # Overview # Create banner # # Referenced global variables # None. #------------------------------------------------------- Banner(config, bsf) = return $(MakeBanner $(config),$(bsf)) #------------------------------------------------------- # Icon # # Overview # Create an icon # # Referenced global variables # None. #------------------------------------------------------- Icon(config, bsf) = return $(MakeIcon $(config),$(bsf)) global.GetExportTypeOption(type) = switch($(type)) case SYMBOL return $(EMPTY) case INDEX return -i case OFFSET return -e eprintln(unknown MODULE_EXPORT_TYPE "$(type)") #-------------------------------------------- private.AddRuleToMakeXrl1st(xrl, plf, isApp, flags) = $(xrl) : $(plf) $(MAKECRO) $(MAKECRO) -l $(if $(isApp),-a) -o $@ $(flags) $< return $(xrl) private.AddRuleToMakeXrlStatic(xrlS, xrl1st, list1st, flags) = $(xrlS) : $(xrl1st) $(list1st) $(MAKECRO) $(MAKECRO) -c -o $@ $(mapprefix -r ,$(list1st)) $(flags) $< return $(xrlS) private.AddRuleToMakeXrl2nd(xrl2nd, xrl1st, xrl) = $(xrl2nd) : $(xrl1st) $(xrl) $(MAKECRO) $(MAKECRO) -m -o $@ -d $(xrl1st) -d $(xrl) -g return $(xrl2nd) private.AddRuleToMakeXrl3rd(xrl3rd, xrl2nd, list2nd) = $(xrl3rd) : $(xrl2nd) $(list2nd) $(MAKECRO) $(MAKECRO) -f -o $@ $(mapprefix -r ,$(list2nd)) $< return $(xrl3rd) private.AddRuleToMakeXrl4th(xrl4th, axf, xrl3rd) = $(xrl4th) : $(axf) $(xrl3rd) $(MAKECRO) $(MAKECRO) -p -o $@ -d $(xrl3rd) $< return $(xrl4th) private.AddRuleToMergeXrl(xrl, xrllist, mn) = $(xrl) : $(xrllist) $(MAKECRO) $(MAKECRO) -m -o $@ $(mapprefix -d ,$(xrllist)) -n "$(mn)" -g return $(xrl) private.AddRuleToMakeEdit(edit, xrl) = $(edit) : $(xrl) $(MAKECRO) $(MAKECRO) -s -o $@ $< return $(edit) private.AddRuleToMakeCmdOpt(cmd, xrl) = $(cmd) : $(xrl) $(MAKECRO) $(MAKECRO) -x -y nnroUnresolved -o $@ $< return $(cmd) private.AddRuleToMakeRo(ro, rlt, axf, xrl, list3rd) = $(rlt) $(ro) : $(axf) $(xrl) $(list3rd) $(MAKECRO) $(MAKECRO) -o $(ro) -t $(rlt) -d $(xrl) $(mapprefix -r ,$(list3rd)) $< return $(ro) private.AddRuleToMakeRs(ro, axf, xrl, list3rd) = $(ro) : $(axf) $(xrl) $(list3rd) $(MAKECRO) $(MAKECRO) -o $(ro) -d $(xrl) $(mapprefix -r ,$(list3rd)) $< return $(ro) private.AddRuleToMakeRr(rr, rlt_list, add_debug) = $(rr): $(makeDirectory $(dirname $(rr))) $(rr) : $(rlt_list) $(MAKECRR) $(MAKECRR) $(if $(add_debug),-d) -o $@ $(mapprefix -r ,$(rlt_list)) return $(rr) private.AddRuleToCopyFile(d, s) = $(d): $(makeDirectory $(dirname $(d))) $(d) : $(s) cp -f $< $@ return $(d) private.AddRuleToReplaceReference(path, raw) = $(path) : $(raw) $(MAKECRO) $(MAKECRO) -u nnroUnresolved -o $@ $< return $(path) private.AddRuleToMakeForceImport(path, xrl) = $(path) : $(makeDirectory $(dirname $(path))) $(path) : $(xrl) $(MAKECRO) -w -o $@ $(xrl) return $(path) private.AddRuleToForceImport(path, axf, list) = $(path) : $(axf) $(list) :value: $(getMtimeIfLarge $(axf)) $(FROMELF) -o $@ $(axf) --elf --via $(list) return $(path) #-------------------------------------------- private.MakePlf(config, name, files, addtional_ldflags) = EXCLUSION_SCATTER = 1 EXT_ELF = $(EXT_PLF) EXT_LDS = $(EXT_PLF)$(EXT_LDS) EXT_MAP = $(EXT_PLF)$(EXT_MAP) EXT_DASM = $(EXT_PLF)$(EXT_DASM) EXT_CG = $(EXT_PLF)$(EXT_CG) DISAS = $(EMPTY) CRT_0_O = $(EMPTY) LDFLAGS += \ --no_scanlib \ --partial \ --vfemode=off \ --diag_suppress=L6475W \ $(addtional_ldflags) public.ELF_FLAGS_HOOK = fun(flags) = return $(filter-out --scanlib --vfemode=force,$(flags)) private.plf = $(ORIGINAL_ExecutableElf $(config), $(name), $(files)) $(plf): $(makeDirectory $(dirname $(plf))) return $(plf) private.MakeXrl1st(config, name, plf, isApp, flags) = private.path = $(config.getBinaryPath $(name), .1$(EXT_XRL)) return $(AddRuleToMakeXrl1st $(path), $(plf), $(isApp), $(flags)) private.MakeXrl2nd(config, name, xrl1st, xrl) = private.path = $(config.getBinaryPath $(name), .2$(EXT_XRL)) if $(xrl) return $(AddRuleToMakeXrl2nd $(path), $(xrl1st), $(xrl)) else return $(AddRuleToCopyFile $(path), $(xrl1st)) private.MakeXrl3rd(config, name, xrl2nd, list2nd) = private.path = $(config.getBinaryPath $(name), .3$(EXT_XRL)) return $(AddRuleToMakeXrl3rd $(path), $(xrl2nd), $(list2nd)) private.MakeXrl4th(config, name, axf, xrl3rd) = private.path = $(config.getBinaryPath $(name), .4$(EXT_XRL)) return $(AddRuleToMakeXrl4th $(path), $(axf), $(xrl3rd)) private.MakeXrlStatic0(config, name, plf, isApp, flags) = private.path = $(config.getBinaryPath $(name), .0$(EXT_XRL)) return $(AddRuleToMakeXrl1st $(path), $(plf), $(isApp), $(flags)) private.MakeXrlStatic1(config, name, xrl1st, xrl) = private.path = $(config.getBinaryPath $(name), .1$(EXT_XRL)) if $(xrl) return $(AddRuleToMakeXrl2nd $(path), $(xrl1st), $(xrl)) else return $(AddRuleToCopyFile $(path), $(xrl1st)) private.MakeXrlStatic2(config, name, xrl1st, list2nd, flags) = private.path = $(config.getBinaryPath $(name), .2$(EXT_XRL)) return $(AddRuleToMakeXrlStatic $(path), $(xrl1st), $(list2nd), $(flags)) private.MakeEdit(config, name, xrl) = private.path = $(config.getBinaryPath $(name), $(EXT_EDIT)) return $(AddRuleToMakeEdit $(path), $(xrl)) private.MakeCmdOpt(config, name, xrl) = private.path = $(config.getBinaryPath $(name), $(EXT_UAE)) return $(AddRuleToMakeCmdOpt $(path), $(xrl)) private.MakeRo(config, name, axf, xrl, list3rd) = private.ro = $(config.getBinaryPath $(name), $(EXT_RO)) private.rlt = $(config.getBinaryPath $(name), $(EXT_RLT)) return $(AddRuleToMakeRo $(ro), $(rlt), $(axf), $(xrl), $(list3rd)) private.MakeRs(config, name, axf, xrl, list3rd) = private.path = $(config.getBinaryPath $(name), $(EXT_RS)) return $(AddRuleToMakeRs $(path), $(axf), $(xrl), $(list3rd)) private.MakeRr(config, name, rlt_list, add_debug) = private.path = $(config.getBinaryPath $(name), $(EXT_RR)) return $(AddRuleToMakeRr $(path), $(rlt_list), $(add_debug)) private.MakeAxfForRo(config, name, src, edit) = private.base = $(makePath $(ROOT_BUILD) linker $(config.platform).Ro.$(config.processor)) LDSCRIPT = $(makePath $(ROOT_RESOURCES) specfiles linker CTR.Ro.MPCore.ldscript) LDFLAGS += \ $(addprefix --edit=,$(edit)) \ --base_platform \ --diag_suppress=L6780W \ --dll \ --no_cppinit \ --no_scanlib \ --override_visi. \ --pltgot=direct \ --undefined_and_export=nnroControlObject_ \ --emit_non_debug_relocs \ $(if $`(ENABLE_CPP_EXCEPTION),--undefined=nnroEitNode_) public.ELF_FLAGS_HOOK = fun(flags) = return $(filter-out --scanlib --vfemode=force --entry=% --keep=nnMain,$(flags)) private.axf = $(ORIGINAL_ExecutableElf $(config), $(name), $(src)) $(axf) : $(edit) return $(axf) private.MakeForceImport(config, name, xrl) = private.path = $(config.getBinaryPath $(name), $(EXT_FIL)) return $(AddRuleToMakeForceImport $(path), $(xrl)) private.ForceImport(config, name, axf, list) = private.path = $(config.getBinaryPath $(name), $(EXT_ELF2)) return $(AddRuleToForceImport $(path), $(axf), $(list)) private.ReplaceReference(config, name, raw) = private.path = $(config.getBinaryPath $(name), .axf) return $(AddRuleToReplaceReference $(path), $(raw)) #-------------------------------------------- global.IsModuleListDefined() = return $(or $(defined MODULE_LIST),$(defined MODULE_LIST_XRL)) global.IsModuleListValid() = return $(or $(and $(defined MODULE_LIST), $(not $(equal $`(MODULE_LIST), $(EMPTY)))),\ $(and $(defined MODULE_LIST_XRL),$(not $(equal $`(MODULE_LIST_XRL),$(EMPTY))))) global.BuildRo(config, name, src, list2nd, list3rd, flags) = DEFAULT_LIBS = $(EMPTY) config.getDefaultLibraries = fun() value $(EMPTY) config.getHostIoLibraries = fun() value $(EMPTY) private.libdir = $(config.getLibraryDirectory false) private.rocrt = $(file $(addprefix $(libdir)$(DIRSEP), $(addsuffix $(EXT_LIB), $(completeLibrarySuffix $(config), libnn_rocrt)))) LDFLAGS += $(rocrt) private.plf = $(MakePlf $(config), $(name), $(src), $(EMPTY)) private.xrl1st = $(MakeXrl1st $(config), $(name), $(plf), false, $(flags)) private.xrl2nd = $(MakeXrl2nd $(config), $(name), $(xrl1st), $(if $(defined MODULE_XRL),$`(MODULE_XRL))) private.xrl3rd = $(MakeXrl3rd $(config), $(name), $(xrl2nd), $(list2nd)) private.edit = $(MakeEdit $(config), $(name), $(xrl3rd)) private.fil = $(MakeForceImport $(config), $(name), $(xrl3rd)) private.axf = $(MakeAxfForRo $(config), $(name), $(src), $(edit)) private.axg = $(ForceImport $(config), $(name), $(axf), $(fil)) private.ro = if $(MODULE_ENABLE_OFFSET) private.xrl4th = $(MakeXrl4th $(config), $(name), $(axg), $(xrl3rd)) value $(MakeRo $(config), $(name), $(axg), $(xrl4th), $(list3rd)) else value $(MakeRo $(config), $(name), $(axg), $(xrl3rd), $(EMPTY)) $(axf) : $(rocrt) return $(ro) private.BuildAxfUsingRo(config, name, files, list2nd, flags) = private.plf = section DEFAULT_LIBS = $(EMPTY) config.getDefaultLibraries = fun() value $(EMPTY) config.getHostIoLibraries = fun() value $(EMPTY) value $(MakePlf $(config), $(name), $(files), $(EMPTY)) private.xrlS0 = $(MakeXrlStatic0 $(config), $(name), $(plf), true, $(flags)) private.xrlS1 = $(MakeXrlStatic1 $(config), $(name), $(xrlS0), $(if $(defined MODULE_XRL),$`(MODULE_XRL))) private.xrlS2 = $(MakeXrlStatic2 $(config), $(name), $(xrlS1), $(list2nd), $(flags)) private.xrl3rd = $(MakeXrl3rd $(config), $(name), $(xrlS2), $(list2nd)) private.edit = $(MakeEdit $(config), $(name), $(xrl3rd)) private.uae = $(MakeCmdOpt $(config), $(name), $(xrl3rd)) private.raw_axf = section public.LIBS += libnn_ro public.LDFLAGS += \ --base_platform \ --diag_suppress=L6780W,L6473W,L6331W \ $(if $(edit),--edit=$(edit)) \ --override_visi. \ --pltgot=direct \ --undefined_and_export=nnroAeabiAtexit_ \ --vfemode=off \ $(if $(uae),--via $(uae)) public.ELF_FLAGS_HOOK = fun(flags) = return $(filter-out --vfemode=force,$(flags)) value $(ORIGINAL_ExecutableElf $(config), $(name), $(files)) private.axf = $(ReplaceReference $(config), $(name).ro, $(raw_axf)) $(raw_axf) : $(edit) $(uae) return $(axf) global.BuildRs(config, name, axf, xrl3rd, list4th) = if $(MODULE_ENABLE_OFFSET) private.xrl4th = $(MakeXrl4th $(config), $(name), $(axf), $(xrl3rd)) return $(MakeRs $(config), $(name), $(axf), $(xrl4th), $(list4th)) else return $(MakeRs $(config), $(name), $(axf), $(xrl3rd), $(EMPTY)) global.CollectXrl2nd(config, module_list) = private.list2nd = foreach(module, $(filter-out $(dir .),$(module_list))) private.name = $(basename $(module)) value $(config.getBinaryPathOf $(module), $(name), .2$(EXT_XRL)) return $(list2nd) global.CollectXrl4th(config, module_list) = private.list4th = foreach(module, $(filter-out $(dir .),$(module_list))) private.name = $(basename $(module)) value $(config.getBinaryPathOf $(module), $(name), .4$(EXT_XRL)) return $(list4th) private.CollectRlt(config, module_list) = private.rlt_list = foreach(module, $(filter-out $(dir .),$(module_list))) private.name = $(basename $(module)) value $(config.getBinaryPathOf $(module), $(name), $(EXT_RLT)) return $(rlt_list) global.ExecutableElfUsingRo(config, name, files) = if $(and $(defined TARGET_PROGRAM),$(IsModuleListDefined)) private.list2nd = if $(IsModuleListDefined) value $(if $(defined MODULE_LIST),$(CollectXrl2nd $(config), $`(MODULE_LIST))) $(if $(defined MODULE_LIST_XRL),$`(MODULE_LIST_XRL)) else value $(EMPTY) private.flags = $(GetExportTypeOption $(MODULE_EXPORT_TYPE)) private.elf = $(BuildAxfUsingRo $(config), $(name), $(files), $(list2nd), $(flags)) return $(elf) else return $(ORIGINAL_ExecutableElf $(config), $(name), $(files)) global.ElfUsingRo(elf, flags, files, depends) = if $(ELF_FLAGS_HOOK) flags = $(ELF_FLAGS_HOOK $(flags)) export flags return $(ORIGINAL_Elf $(elf), $(flags), $(files), $(depends)) global.BuildRr(config, name, module_list, add_debug) = private.rlt_list = $(CollectRlt $(config), $(module_list)) return $(MakeRr $(config), $(name), $(rlt_list), $(add_debug))