#setup
$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.rz: $(OBSEG_DIR)/setup/$(COUNTRYCODE)/%.bin
	$(RZ_COMP) $< $@

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.rz: $(OBSEG_DIR)/setup/%.bin
	$(RZ_COMP) $< $@

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.rz: $(BUILD_DIR)/$(OBSEG_DIR)/setup/%.bin
	$(RZ_COMP) $< $@

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.bin: $(BUILD_DIR)/$(OBSEG_DIR)/setup/%.elf
	$(OBJCOPY) $< $@ -O binary

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.elf: $(BUILD_DIR)/$(OBSEG_DIR)/setup/%.o
	$(LD) -T assets/obseg/setup/Usetup.ld -o $@ $<

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.o: $(OBSEG_DIR)/setup/$(COUNTRYCODE)/%.c
	$(CC) -c $(CFLAGS) -o $@ -O2 $<

$(BUILD_DIR)/$(OBSEG_DIR)/setup/%.o: $(OBSEG_DIR)/setup/%.c
#	$(CC) -c $(CFLAGS) -o $@ -O2 $<
 #	convert AI_PRINT commands from readable to byte-array
	$(ConvertAIPRINT) $< | $(CC) -c $(CFLAGS) tools/asm-processor/include-stdin.c -o $@ $(OPTIMIZATION)

SETUP_NAMES := \
    Ump_setupameZ \
    Ump_setuparchZ \
    Ump_setuparkZ \
    Ump_setupashZ \
    Ump_setupcaveZ \
    Ump_setupcradZ \
    Ump_setupcrypZ \
    Ump_setupdishZ \
    Ump_setupimpZ \
    Ump_setupoatZ \
    Ump_setuprefZ \
    Ump_setupsevbZ \
    Ump_setupstatueZ \
    UsetuparchZ \
    UsetuparkZ \
    UsetupaztZ \
    UsetupcaveZ \
    UsetupcontrolZ \
    UsetupcradZ \
    UsetupcrypZ \
    UsetupdamZ \
    UsetupdepoZ \
    UsetupdestZ \
    UsetupjunZ \
    UsetuplenZ \
    UsetuppeteZ \
    UsetuprunZ \
    UsetupsevbZ \
    UsetupsevbunkerZ \
    UsetupsevxZ \
    UsetupsevxbZ \
    UsetupsiloZ \
    UsetupstatueZ \
    UsetuptraZ

SETUP_O_FILES := $(foreach name,$(SETUP_NAMES),$(BUILD_DIR)/$(OBSEG_DIR)/setup/$(name).o)
SETUP_BIN_FILES := $(foreach name,$(SETUP_NAMES),$(BUILD_DIR)/$(OBSEG_DIR)/setup/$(name).bin)
SETUP_ELF_FILES := $(foreach name,$(SETUP_NAMES),$(BUILD_DIR)/$(OBSEG_DIR)/setup/$(name).elf)
SETUP_RZ_FILES := $(foreach name,$(SETUP_NAMES),$(BUILD_DIR)/$(OBSEG_DIR)/setup/$(name).rz)

SETUP_BUILD_FILES := $(SETUP_O_FILES) $(SETUP_BIN_FILES) $(SETUP_ELF_FILES) $(SETUP_RZ_FILES)
