1include version.all 2 3#--------------------------------------------------------------------------------- 4.SUFFIXES: 5#--------------------------------------------------------------------------------- 6 7ifeq ($(strip $(DEVKITPRO)),) 8$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro") 9endif 10 11TOPDIR ?= $(CURDIR) 12include $(DEVKITPRO)/libnx/switch_rules 13 14TARGET := retroarch_switch 15 16DEBUG ?= 0 17WHOLE_ARCHIVE_LINK = 0 18GRIFFIN_BUILD = 0 19 20OBJ := 21 22DEFINES := -D__SWITCH__=1 -U__linux__ -U__linux -DGLM_FORCE_PURE=1 -DRARCH_CONSOLE -DRARCH_INTERNAL -DGLOBAL_CONFIG_DIR='"/switch"' -DHAVE_STB_VORBIS 23 24HAVE_DR_MP3 = 1 25HAVE_TRANSLATE = 1 26HAVE_SCREENSHOTS = 1 27HAVE_REWIND = 1 28HAVE_AUDIOMIXER = 1 29HAVE_CC_RESAMPLER = 1 30HAVE_MENU_COMMON = 1 31HAVE_RTGA = 1 32HAVE_RPNG = 1 33HAVE_RJPEG = 1 34HAVE_RBMP = 1 35HAVE_7ZIP = 1 36HAVE_ZLIB = 1 37HAVE_BUILTINZLIB = 1 38HAVE_LIBRETRODB = 1 39HAVE_DSP_FILTER = 1 40HAVE_VIDEO_FILTER = 1 41HAVE_STATIC_VIDEO_FILTERS = 1 42HAVE_STATIC_AUDIO_FILTERS = 1 43HAVE_MENU = 1 44HAVE_CONFIGFILE = 1 45HAVE_PATCH = 1 46HAVE_CHEATS = 1 47HAVE_RUNAHEAD = 1 48HAVE_NETWORKING = 1 49HAVE_NETPLAYDISCOVERY = 1 50HAVE_STB_FONT = 1 51HAVE_CHEEVOS = 1 52HAVE_CHD = 0 # disabled due to static libretro-common and libchdr conflicts between different cores 53HAVE_STB_VORBIS = 1 54HAVE_IBXM = 1 55 56# RetroArch libnx useful flags 57HAVE_THREADS = 1 58HAVE_PTHREADS = 1 59HAVE_FREETYPE = 0 60HAVE_SWITCH = 1 61HAVE_LIBNX = 1 62HAVE_OPENGL = 1 63HAVE_LANGEXTRA = 1 64HAVE_GFX_WIDGETS = 1 65 66ifeq ($(HAVE_OPENGL), 1) 67 HAVE_EGL = 1 68 HAVE_SHADERPIPELINE = 1 69 HAVE_RGUI = 1 70 HAVE_MATERIALUI = 1 71 HAVE_XMB = 1 72 HAVE_OZONE = 1 73 HAVE_OVERLAY = 1 74 HAVE_VIDEO_LAYOUT = 1 75 HAVE_GLSL = 1 76else 77 HAVE_RGUI = 1 78 HAVE_MATERIALUI = 0 79 HAVE_XMB = 0 80 HAVE_OZONE = 0 81 HAVE_STRIPES = 0 82endif 83 84include Makefile.common 85BLACKLIST := 86 87OBJ := $(filter-out $(BLACKLIST),$(OBJ)) 88 89#--------------------------------------------------------------------------------- 90# TARGET is the name of the output 91# BUILD is the directory where object files & intermediate files will be placed 92# SOURCES is a list of directories containing source code 93# DATA is a list of directories containing data files 94# INCLUDES is a list of directories containing header files 95# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". 96# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional) 97# 98# NO_ICON: if set to anything, do not use icon. 99# NO_NACP: if set to anything, no .nacp file is generated. 100# APP_TITLE is the name of the app stored in the .nacp file (Optional) 101# APP_AUTHOR is the author of the app stored in the .nacp file (Optional) 102# APP_VERSION is the version of the app stored in the .nacp file (Optional) 103# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) 104# ICON is the filename of the icon (.jpg), relative to the project folder. 105# If not set, it attempts to use one of the following (in this order): 106# - <Project name>.jpg 107# - icon.jpg 108# - <libnx folder>/default_icon.jpg 109#--------------------------------------------------------------------------------- 110BUILD := build 111SOURCES := $(CURDIR)/source 112DATA := data 113INCLUDES := include 114EXEFS_SRC := exefs_src 115#ROMFS := switch/romfs 116 117APP_TITLE := RetroArch 118APP_VERSION := $(RARCH_VERSION) 119APP_AUTHOR := libretro Team 120APP_ICON := pkg/libnx/retroarch.jpg 121 122#--------------------------------------------------------------------------------- 123# options for code generation 124#--------------------------------------------------------------------------------- 125ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -mcpu=cortex-a57+crc+fp+simd 126 127CFLAGS := -g -Wall -O3 -fcommon -ffast-math -ffunction-sections \ 128 $(ARCH) $(DEFINES) $(INCLUDE_DIRS) -I$(LIBNX)/include -I$(PORTLIBS)/include/ -include $(LIBNX)/include/switch.h #$(shell $(PORTLIBS)/bin/freetype-config --cflags) 129 130CFLAGS += $(INCLUDE) -DSWITCH=1 -DHAVE_LIBNX=1 -DNXLINK=1 -DHAVE_SHADERPIPELINE -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_STB_FONT #-DHAVE_FREETYPE 131 132ifeq ($(strip $(HAVE_STATIC_DUMMY)),1) 133 CFLAGS += -DHAVE_STATIC_DUMMY=1 134endif 135 136CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 137 138ASFLAGS := -g $(ARCH) 139LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs $(ARCH) -Wl,--allow-multiple-definition -Wl,-Map,$(notdir $*.map) 140 141# add things from Makefile.common 142CFLAGS += $(DEF_FLAGS) 143 144LIBS := -lswresample -lavformat -lavcodec -lavutil -lswscale -lstdc++ -lbz2 -lpng -lz -lnx -lvpx -lopus -llzma -lm 145 146ifeq ($(HAVE_OPENGL), 1) 147 LIBS := -lEGL -lglapi -ldrm_nouveau $(LIBS) 148endif 149 150#--------------------------------------------------------------------------------- 151# list of directories containing libraries, this must be the top level containing 152# include and lib 153#--------------------------------------------------------------------------------- 154LIBDIRS := $(PORTLIBS) $(LIBNX) 155 156#--------------------------------------------------------------------------------- 157# no real need to edit anything past this point unless you need to add additional 158# rules for different file extensions 159#--------------------------------------------------------------------------------- 160ifneq ($(BUILD),$(notdir $(CURDIR))) 161#--------------------------------------------------------------------------------- 162 163export OUTPUT := $(TARGET) 164export TOPDIR := $(CURDIR) 165 166export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 167 $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 168 169export DEPSDIR := $(CURDIR)/ 170 171CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 172CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 173SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 174BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 175 176#--------------------------------------------------------------------------------- 177# use CXX for linking C++ projects, CC for standard C 178#--------------------------------------------------------------------------------- 179ifeq ($(strip $(CPPFILES)),) 180#--------------------------------------------------------------------------------- 181 export LD := $(CC) 182#--------------------------------------------------------------------------------- 183else 184#--------------------------------------------------------------------------------- 185 export LD := $(CXX) 186#--------------------------------------------------------------------------------- 187endif 188#--------------------------------------------------------------------------------- 189 190export OFILES := $(OBJ) 191 192ifeq ($(strip $(HAVE_STATIC_DUMMY)),) 193 OFILES += libretro_libnx.a 194endif 195 196export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) 197 198export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 199 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 200 -I$(CURDIR)/$(BUILD) 201 202export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 203 204export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC) 205 206ifeq ($(strip $(ICON)),) 207 icons := $(wildcard *.jpg) 208 ifneq (,$(findstring $(TARGET).jpg,$(icons))) 209 export APP_ICON := $(TOPDIR)/$(TARGET).jpg 210 else 211 ifneq (,$(findstring icon.jpg,$(icons))) 212 export APP_ICON := $(TOPDIR)/icon.jpg 213 endif 214 endif 215else 216 export APP_ICON := $(TOPDIR)/$(ICON) 217endif 218 219ifeq ($(strip $(NO_ICON)),) 220 export NROFLAGS += --icon=$(APP_ICON) 221endif 222 223ifeq ($(strip $(NO_NACP)),) 224 export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp 225endif 226 227ifneq ($(APP_TITLEID),) 228 export NACPFLAGS += --titleid=$(APP_TITLEID) 229endif 230 231ifneq ($(ROMFS),) 232 export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) 233endif 234 235DEPENDS_TMP := $(OFILES:.o=.d) 236DEPENDS := $(filter-out libretro_libnx.a,$(DEPENDS_TMP)) 237 238.PHONY: clean all 239 240#--------------------------------------------------------------------------------- 241# main targets 242#--------------------------------------------------------------------------------- 243all : $(OUTPUT).pfs0 $(OUTPUT).nro 244 245$(OUTPUT).pfs0 : $(OUTPUT).nso 246 247$(OUTPUT).nso : $(OUTPUT).elf 248 249ifeq ($(strip $(NO_NACP)),) 250$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp 251else 252$(OUTPUT).nro : $(OUTPUT).elf 253endif 254 255$(OUTPUT).elf : $(OBJ) 256 257clean: 258 rm -f $(DEPENDS) $(OBJ) $(OUTPUT).pfs0 $(OUTPUT).nro $(OUTPUT).elf 259 260#--------------------------------------------------------------------------------- 261# you need a rule like this for each extension you use as binary data 262#--------------------------------------------------------------------------------- 263%.bin.o %_bin.h : %.bin 264#--------------------------------------------------------------------------------- 265 @echo $(notdir $<) 266 @$(bin2o) 267 268#--------------------------------------------------------------------------------------- 269endif 270#--------------------------------------------------------------------------------------- 271