export OBJDUMP	:=	arm-none-eabi-objdump

dirname   = $(shell dirname $(1))

rwildcard = $(foreach d, $(wildcard $1*), \
            $(filter $(subst *, %, $2), $d) \
            $(call rwildcard, $d/, $2))

FLAVOR  ?=  GodMode9
SPLASH   =  resources/$(FLAVOR)_splash.png

ifeq ($(FLAVOR),SafeMode9)
    CFLAGS += -DSAFEMODE
else ifeq ($(FLAVOR),GodMode64)
    OVERRIDE_FONT := resources/fonts/font_c64_8x8.pbm
    CFLAGS += -DDEFAULT_FONT=\"font_c64_8x8.pbm\"
    CFLAGS += -DCOLOR_STD_FONT="RGB(0x7B, 0x71, 0xD5)"
    CFLAGS += -DCOLOR_STD_BG="RGB(0x41, 0x30, 0xA4)"
else ifeq ($(FLAVOR),BrickedMode9)
    OVERRIDE_FONT := resources/fonts/font_nbraille_4x6.pbm
    CFLAGS += -DDEFAULT_FONT=\"font_nbraille_4x6.pbm\"
    CFLAGS += -DCOLOR_STD_FONT="RGB(0xFF, 0xFF, 0x00)"
    CFLAGS += -DCOLOR_STD_BG="RGB(0x00, 0x00, 0xFF)"
else ifeq ($(FLAVOR),ZuishMode9)
    OVERRIDE_FONT := resources/fonts/font_zuish_8x8.pbm
    CFLAGS += -DDEFAULT_FONT=\"font_zuish_8x8.pbm\"
endif

ifeq ($(LARGEDLC),1)
    CFLAGS += -DTITLE_MAX_CONTENTS=1536
else
    CFLAGS += -DTITLE_MAX_CONTENTS=1024
endif

ifeq ($(SALTMODE),1)
    CFLAGS += -DSALTMODE
endif

ifeq ($(SWITCH_SCREENS),1)
    CFLAGS += -DSWITCH_SCREENS
endif

ifeq ($(SCRIPT_RUNNER),1)
    CFLAGS += -DSCRIPT_RUNNER
endif

ifeq ($(AUTO_UNLOCK),1)
    CFLAGS += -DAUTO_UNLOCK
endif

ifeq ($(TIMER_UNLOCK),1)
    CFLAGS += -DTIMER_UNLOCK
endif

ifeq ($(HIDE_HIDDEN),1)
    CFLAGS += -DHIDE_HIDDEN
endif

ifeq ($(SHOW_FREE),1)
    CFLAGS += -DSHOW_FREE
endif

ifdef FIXED_BRIGHTNESS
    CFLAGS += -DFIXED_BRIGHTNESS=$(FIXED_BRIGHTNESS)
endif

ifdef SD_TIMEOUT
    CFLAGS += -DSD_TIMEOUT=$(SD_TIMEOUT)
endif

ifeq ($(NO_LUA),1)
    CFLAGS += -DNO_LUA
endif

ifdef N_PANES
    CFLAGS += -DN_PANES=$(N_PANES)
endif

ifeq ($(MONITOR_HEAP),1)
    CFLAGS += -DMONITOR_HEAP
endif

ifdef NTRBOOT
    FTFLAGS  = -S spi-retail
    FTDFLAGS = -S spi-dev
    FIRM     = $(OUTDIR)/$(FLAVOR)_ntr.firm
    FIRMD    = $(OUTDIR)/$(FLAVOR)_ntr_dev.firm
else
    FTFLAGS  = -S nand-retail
    FTDFLAGS = -S nand-dev
    FIRM     = $(OUTDIR)/$(FLAVOR).firm
    FIRMD    = $(OUTDIR)/$(FLAVOR)_dev.firm
endif
