2015-04-01 21:14:13 +00:00
TARGET := retroarch_3ds
2015-09-11 21:10:03 +00:00
LIBRETRO =
2015-09-11 21:07:12 +00:00
2015-04-01 21:14:13 +00:00
DEBUG = 0
2015-09-11 21:07:12 +00:00
APP_TITLE = Retroarch 3DS
APP_DESCRIPTION = Retroarch 3DS
APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RETROARCH-3DS
APP_UNIQUE_ID = 0xBAC00
APP_ICON = ctr/default.png
APP_BANNER = ctr/libretro_banner.png
APP_AUDIO = ctr/silent.wav
i f e q ( $( LIBRETRO ) , g a m b a t t e )
APP_TITLE = Gambatte Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-GAMBATTE
APP_UNIQUE_ID = 0xBAC01
APP_ICON = ctr/gambatte.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , g p s p )
APP_TITLE = gpSP Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-GPSP
APP_UNIQUE_ID = 0xBAC02
APP_ICON = ctr/gpsp.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , f c e u m m )
APP_TITLE = FCeumm Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-FCEUMM
APP_UNIQUE_ID = 0xBAC03
APP_ICON = ctr/fceumm.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , n e s t o p i a )
APP_TITLE = Nestopia Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-NESTOPIA
APP_UNIQUE_ID = 0xBAC04
APP_ICON = ctr/nestopia.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , n x e n g i n e )
APP_TITLE = NXengine Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-NXENGINE
APP_UNIQUE_ID = 0xBAC05
APP_ICON = ctr/nxengine.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , g e n e s i s _ p l u s _ g x )
APP_TITLE = Genesis Plus GX Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-GENPLUSGX
APP_UNIQUE_ID = 0xBAC06
APP_ICON = ctr/gambatte.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e l s e i f e q ( $( LIBRETRO ) , c a t s f c )
APP_TITLE = CATSFC Libretro
#APP_DESCRIPTION = Retroarch 3DS
#APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RARCH-CATSFC
APP_UNIQUE_ID = 0xBAC07
APP_ICON = ctr/gambatte.png
#APP_BANNER = ctr/libretro_banner.png
#APP_AUDIO = ctr/silent.wav
e n d i f
OBJS :=
OBJS += gfx/drivers/ctr_sprite.o
OBJS += griffin/griffin.o
2015-04-01 21:14:13 +00:00
2015-04-01 22:27:55 +00:00
i f e q ( $( strip $ ( DEVKITARM ) ) , )
$( error "Please set DEVKITARM in your environment . export DEVKITARM =<path to >devkitARM ")
e n d i f
2015-04-01 21:14:13 +00:00
2015-04-01 22:27:55 +00:00
i f e q ( $( strip $ ( CTRULIB ) ) , )
$( error "Please set CTRULIB in your environment . export CTRULIB =<path to >ctrulib ")
e n d i f
i f e q ( $( strip $ ( AEMSTRO ) ) , )
$( error "Please set AEMSTRO in your environment . export AEMSTRO =<path to >aemstro ")
e n d i f
2015-04-01 21:14:13 +00:00
2015-09-11 21:07:12 +00:00
APP_TITLE := $( shell echo " $( APP_TITLE) " | cut -c1-128)
APP_DESCRIPTION := $( shell echo " $( APP_DESCRIPTION) " | cut -c1-256)
APP_AUTHOR := $( shell echo " $( APP_AUTHOR) " | cut -c1-128)
APP_PRODUCT_CODE := $( shell echo $( APP_PRODUCT_CODE) | cut -c1-16)
APP_UNIQUE_ID := $( shell echo $( APP_UNIQUE_ID) | cut -c1-7)
2015-04-01 21:14:13 +00:00
INCDIRS := -I$( CTRULIB) /include
LIBDIRS := -L. -L$( CTRULIB) /lib
2015-09-11 21:07:12 +00:00
ARCH := -march= armv6k -mtune= mpcore -mfloat-abi= hard -marm -mfpu= vfp
2015-04-01 21:14:13 +00:00
CFLAGS += -mword-relocations \
-fomit-frame-pointer -ffast-math \
$( ARCH)
#CFLAGS += -Wall
CFLAGS += -DARM11 -D_3DS
i f e q ( $( DEBUG ) , 1 )
CFLAGS += -O0 -g
e l s e
CFLAGS += -O3
e n d i f
CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
CFLAGS += -DHAVE_GRIFFIN= 1 -DHAVE_FILTERS_BUILTIN -DHAVE_MENU -DHAVE_RGUI
2015-04-19 14:55:03 +00:00
CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
2015-04-08 20:35:10 +00:00
#-DHAVE_LIBRETRO_MANAGEMENT -DWANT_RPNG -DHAVE_7ZIP
2015-04-01 21:14:13 +00:00
CXXFLAGS := $( CFLAGS) -fno-rtti -fno-exceptions -std= gnu++11
2015-09-11 21:07:12 +00:00
ASFLAGS := -g $( ARCH) -O3
2015-04-01 21:14:13 +00:00
LDFLAGS = -specs= 3dsx.specs -g $( ARCH) -Wl,-Map,$( notdir $* .map)
2015-09-11 21:07:12 +00:00
2015-04-01 21:14:13 +00:00
CFLAGS += -std= gnu99 -ffast-math
LIBS := -lretro_ctr -lctru -lm
.PHONY : $( BUILD ) clean all
all : $( TARGET )
2015-09-11 21:07:12 +00:00
$(TARGET) : $( TARGET ) .3dsx $( TARGET ) .smdh $( TARGET ) .cia
$(TARGET).3dsx : $( TARGET ) .elf
$(TARGET).elf : $( OBJS ) libretro_ctr .a
2015-04-01 21:14:13 +00:00
2015-09-11 21:07:12 +00:00
ctr_sprite_shader_shbin.h : gfx /drivers /ctr_sprite .o
gfx/drivers/ctr_gfx.c : ctr_sprite_shader_shbin .h
griffin/griffin.c : gfx /drivers /ctr_gfx .c
2015-04-01 21:14:13 +00:00
PREFIX := $( DEVKITARM) /bin/arm-none-eabi-
CC := $( PREFIX) gcc
CXX := $( PREFIX) g++
AS := $( PREFIX) as
AR := $( PREFIX) ar
OBJCOPY := $( PREFIX) objcopy
STRIP := $( PREFIX) strip
NM := $( PREFIX) nm
LD := $( CXX)
2015-09-11 21:07:12 +00:00
i f n e q ( $( findstring Linux ,$ ( shell uname -a ) ) , )
MAKEROM = ctr/tools/makerom-linux
BANNERTOOL = ctr/tools/bannertool-linux
e l s e i f n e q ( $( findstring Darwin ,$ ( shell uname -a ) ) , )
MAKEROM = ctr/tools/makerom-mac
BANNERTOOL = ctr/tools/bannertool-mac
e l s e
MAKEROM = ctr/tools/makerom.exe
BANNERTOOL = ctr/tools/bannertool.exe
e n d i f
2015-04-01 21:14:13 +00:00
%.o : %.shader
python $( AEMSTRO) /aemstro_as.py $< $( notdir $<) .shbin
2015-09-07 17:31:30 +00:00
$( DEVKITARM) /bin/bin2s $( notdir $<) .shbin | $( PREFIX) as -o $@
2015-04-01 21:14:13 +00:00
echo "extern const u8" ` ( echo $( notdir $<) .shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _) ` "_end[];" > ` ( echo $( notdir $<) .shbin | tr . _) ` .h
echo "extern const u8" ` ( echo $( notdir $<) .shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _) ` "[];" >> ` ( echo $( notdir $<) .shbin | tr . _) ` .h
echo "extern const u32" ` ( echo $( notdir $<) .shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _) ` _size";" >> ` ( echo $( notdir $<) .shbin | tr . _) ` .h
rm $( notdir $<) .shbin
%.o : %.cpp
$( CXX) -c -o $@ $< $( CXXFLAGS) $( INCDIRS)
%.o : %.c
$( CC) -c -o $@ $< $( CFLAGS) $( INCDIRS)
%.o : %.s
$( CC) -c -o $@ $< $( ASFLAGS)
%.o : %.S
$( CC) -c -o $@ $< $( ASFLAGS)
%.a :
$( AR) -rc $@ $^
%.vsh :
2015-09-11 21:07:12 +00:00
%.smdh : $( APP_ICON )
2015-04-01 21:14:13 +00:00
smdhtool --create " $( APP_TITLE) " " $( APP_DESCRIPTION) " " $( APP_AUTHOR) " $( APP_ICON) $@
%.3dsx : %.elf
2015-09-11 21:07:12 +00:00
-3dsxtool $< $@ $( _3DSXFLAGS)
2015-04-01 21:14:13 +00:00
2015-09-11 21:07:12 +00:00
%.elf :
2015-04-01 21:14:13 +00:00
$( LD) $( LDFLAGS) $( OBJS) $( LIBDIRS) $( LIBS) -o $@
$( NM) -CSn $@ > $( notdir $* .lst)
2015-09-11 21:07:12 +00:00
$(TARGET).bnr : $( APP_BANNER ) $( APP_AUDIO )
$( BANNERTOOL) makebanner -i " $( APP_BANNER) " -a " $( APP_AUDIO) " -o $@
$(TARGET).icn : $( APP_ICON )
$( BANNERTOOL) makesmdh -s " $( APP_TITLE) " -l " $( APP_TITLE) " -p " $( APP_AUTHOR) " -i $( APP_ICON) -o $@
$(TARGET).rsf : ctr /tools /template -cia .rsf
cat ctr/tools/template-cia.rsf | sed 's/{APP_TITLE}/$(APP_TITLE)/' | sed 's/{APP_PRODUCT_CODE}/$(APP_PRODUCT_CODE)/' | sed 's/{APP_UNIQUE_ID}/$(APP_UNIQUE_ID)/' > $@
$(TARGET)_stripped.elf : $( TARGET ) .elf
cp $( TARGET) .elf $@
$( STRIP) $@
$(TARGET).cia : $( TARGET ) _stripped .elf $( TARGET ) .bnr $( TARGET ) .icn $( TARGET ) .rsf
$( MAKEROM) -f cia -o $@ -rsf $( TARGET) .rsf -target t -exefslogo -elf $( TARGET) _stripped.elf -icon $( TARGET) .icn -banner $( TARGET) .bnr
2015-04-01 21:14:13 +00:00
2015-09-11 21:07:12 +00:00
clean :
rm -f $( OBJS)
rm -f $( TARGET) .3dsx
rm -f $( TARGET) .elf
rm -f $( TARGET) _stripped.elf
rm -f $( TARGET) .cia
rm -f $( TARGET) .bnr
rm -f $( TARGET) .icn
rm -f $( TARGET) .rsf
rm -f *_shader_shbin.h
.PHONY : clean
2015-04-08 17:59:41 +00:00