| 1 | # Makefile for PCSX ReARMed (libretro) |
| 2 | |
| 3 | DEBUG=0 |
| 4 | WANT_ZLIB=1 |
| 5 | |
| 6 | ifeq ($(platform),) |
| 7 | platform = unix |
| 8 | ifeq ($(shell uname -a),) |
| 9 | platform = win |
| 10 | else ifneq ($(findstring MINGW,$(shell uname -a)),) |
| 11 | platform = win |
| 12 | else ifneq ($(findstring Darwin,$(shell uname -a)),) |
| 13 | platform = osx |
| 14 | else ifneq ($(findstring win,$(shell uname -a)),) |
| 15 | platform = win |
| 16 | endif |
| 17 | endif |
| 18 | |
| 19 | CC ?= gcc |
| 20 | CXX ?= g++ |
| 21 | AS ?= as |
| 22 | CC_AS ?= $(CC) |
| 23 | CFLAGS ?= |
| 24 | |
| 25 | TARGET_NAME := pcsx_rearmed |
| 26 | GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)" |
| 27 | ifneq ($(GIT_VERSION)," unknown") |
| 28 | CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" |
| 29 | endif |
| 30 | ifneq ($(WANT_ZLIB),1) |
| 31 | LIBZ := -lz |
| 32 | endif |
| 33 | LIBPTHREAD := -lpthread |
| 34 | ifneq ($(findstring Haiku,$(shell uname -s)),) |
| 35 | LIBDL := -lroot -lnetwork |
| 36 | else |
| 37 | LIBDL := -ldl |
| 38 | endif |
| 39 | LIBM := -lm |
| 40 | MMAP_WIN32=0 |
| 41 | EXTRA_LDFLAGS = |
| 42 | |
| 43 | # Unix |
| 44 | ifeq ($(platform), unix) |
| 45 | TARGET := $(TARGET_NAME)_libretro.so |
| 46 | fpic := -fPIC |
| 47 | ifneq ($(findstring SunOS,$(shell uname -s)),) |
| 48 | CC = gcc |
| 49 | endif |
| 50 | |
| 51 | else ifeq ($(platform), linux-portable) |
| 52 | TARGET := $(TARGET_NAME)_libretro.so |
| 53 | fpic := -fPIC -nostdlib |
| 54 | EXTRA_LDFLAGS += -fPIC -nostdlib |
| 55 | LIBZ := |
| 56 | LIBPTHREAD := |
| 57 | LIBDL := |
| 58 | LIBM := |
| 59 | NO_UNDEF_CHECK = 1 |
| 60 | |
| 61 | # OS X |
| 62 | else ifeq ($(platform), osx) |
| 63 | USE_DYNAREC ?= 1 |
| 64 | TARGET := $(TARGET_NAME)_libretro.dylib |
| 65 | fpic := -fPIC |
| 66 | fpic += -mmacosx-version-min=10.1 |
| 67 | ifeq ($(USE_DYNAREC),0) |
| 68 | # Override |
| 69 | TARGET := $(TARGET_NAME)_interpreter_libretro.dylib |
| 70 | endif |
| 71 | |
| 72 | # iOS |
| 73 | else ifeq ($(platform),$(filter $(platform),ios-arm64)) |
| 74 | ARCH := arm64 |
| 75 | USE_DYNAREC = 0 |
| 76 | HAVE_NEON = 0 |
| 77 | BUILTIN_GPU = peops |
| 78 | TARGET := $(TARGET_NAME)_libretro_ios.dylib |
| 79 | |
| 80 | else ifneq (,$(findstring ios,$(platform))) |
| 81 | ARCH := arm |
| 82 | USE_DYNAREC ?= 1 |
| 83 | HAVE_NEON = 1 |
| 84 | BUILTIN_GPU = neon |
| 85 | TARGET := $(TARGET_NAME)_libretro_ios.dylib |
| 86 | ifeq ($(USE_DYNAREC),0) |
| 87 | # Override |
| 88 | TARGET := $(TARGET_NAME)_interpreter_libretro_ios.dylib |
| 89 | endif |
| 90 | fpic := -fPIC |
| 91 | |
| 92 | ifeq ($(IOSSDK),) |
| 93 | IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) |
| 94 | endif |
| 95 | |
| 96 | CC = clang -arch armv7 -isysroot $(IOSSDK) |
| 97 | CXX = clang++ -arch armv7 -isysroot $(IOSSDK) |
| 98 | CC_AS = perl ./tools/gas-preprocessor.pl $(CC) |
| 99 | CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm |
| 100 | ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon |
| 101 | CFLAGS += -DIOS |
| 102 | ifeq ($(platform),ios9) |
| 103 | CC += -miphoneos-version-min=8.0 |
| 104 | CXX += -miphoneos-version-min=8.0 |
| 105 | CC_AS += -miphoneos-version-min=8.0 |
| 106 | CFLAGS += -miphoneos-version-min=8.0 |
| 107 | else |
| 108 | CC += -miphoneos-version-min=5.0 |
| 109 | CXX += -miphoneos-version-min=5.0 |
| 110 | CC_AS += -miphoneos-version-min=5.0 |
| 111 | CFLAGS += -miphoneos-version-min=5.0 |
| 112 | endif |
| 113 | |
| 114 | # PS3 |
| 115 | else ifeq ($(platform), ps3) |
| 116 | TARGET := $(TARGET_NAME)_libretro_ps3.a |
| 117 | CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe |
| 118 | AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe |
| 119 | CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ |
| 120 | |
| 121 | # sncps3 |
| 122 | else ifeq ($(platform), sncps3) |
| 123 | TARGET := $(TARGET_NAME)_libretro_ps3.a |
| 124 | CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe |
| 125 | AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe |
| 126 | CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ |
| 127 | |
| 128 | # Lightweight PS3 Homebrew SDK |
| 129 | else ifeq ($(platform), psl1ght) |
| 130 | TARGET := $(TARGET_NAME)_libretro_psl1ght.a |
| 131 | CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT) |
| 132 | AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT) |
| 133 | CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__ |
| 134 | |
| 135 | # PSP |
| 136 | else ifeq ($(platform), psp1) |
| 137 | TARGET := $(TARGET_NAME)_libretro_psp1.a |
| 138 | CC = psp-gcc$(EXE_EXT) |
| 139 | AR = psp-ar$(EXE_EXT) |
| 140 | CFLAGS += -DPSP -G0 |
| 141 | |
| 142 | # Vita |
| 143 | else ifeq ($(platform), vita) |
| 144 | TARGET := $(TARGET_NAME)_libretro_vita.a |
| 145 | CC = arm-vita-eabi-gcc$(EXE_EXT) |
| 146 | AR = arm-vita-eabi-ar$(EXE_EXT) |
| 147 | CFLAGS += -DVITA |
| 148 | CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm |
| 149 | CFLAGS += -fsingle-precision-constant -mword-relocations -fno-unwind-tables |
| 150 | CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops |
| 151 | CFLAGS += -fno-optimize-sibling-calls |
| 152 | CFLAGS += -I$(VITASDK)/include -Ifrontend/vita |
| 153 | CFLAGS += -DNO_SOCKET -DNO_OS -DNO_DYLIB |
| 154 | ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon |
| 155 | |
| 156 | # CFLAGS += -U__ARM_NEON__ |
| 157 | HAVE_NEON = 1 |
| 158 | BUILTIN_GPU = neon |
| 159 | |
| 160 | USE_DYNAREC = 1 |
| 161 | DRC_CACHE_BASE = 0 |
| 162 | |
| 163 | ARCH = arm |
| 164 | STATIC_LINKING = 1 |
| 165 | |
| 166 | # CTR(3DS) |
| 167 | else ifeq ($(platform), ctr) |
| 168 | TARGET := $(TARGET_NAME)_libretro_ctr.a |
| 169 | CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT) |
| 170 | CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) |
| 171 | AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) |
| 172 | CFLAGS += -DARM11 -D_3DS -DNO_OS -DNO_DYLIB -DNO_SOCKET |
| 173 | CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft |
| 174 | CFLAGS += -Wall -mword-relocations |
| 175 | CFLAGS += -fomit-frame-pointer -ffast-math |
| 176 | CFLAGS += -Ifrontend/3ds |
| 177 | CFLAGS += -Werror=implicit-function-declaration |
| 178 | |
| 179 | # CFLAGS += -DPCSX |
| 180 | BUILTIN_GPU = unai |
| 181 | USE_DYNAREC = 1 |
| 182 | DRC_CACHE_BASE = 0 |
| 183 | ARCH = arm |
| 184 | HAVE_NEON = 0 |
| 185 | |
| 186 | STATIC_LINKING = 1 |
| 187 | |
| 188 | # Xbox 360 |
| 189 | else ifeq ($(platform), xenon) |
| 190 | TARGET := $(TARGET_NAME)_libretro_xenon360.a |
| 191 | CC = xenon-gcc$(EXE_EXT) |
| 192 | AR = xenon-ar$(EXE_EXT) |
| 193 | CFLAGS += -D__LIBXENON__ -m32 -D__ppc__ |
| 194 | |
| 195 | # Nintendo Game Cube |
| 196 | else ifeq ($(platform), ngc) |
| 197 | TARGET := $(TARGET_NAME)_libretro_ngc.a |
| 198 | CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) |
| 199 | AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) |
| 200 | CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ |
| 201 | |
| 202 | # Nintendo Wii |
| 203 | else ifeq ($(platform), wii) |
| 204 | TARGET := libretro_$(TARGET_NAME)_wii.a |
| 205 | CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) |
| 206 | AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) |
| 207 | CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__ |
| 208 | |
| 209 | # QNX |
| 210 | else ifeq ($(platform), qnx) |
| 211 | TARGET := $(TARGET_NAME)_libretro_qnx.so |
| 212 | fpic := -fPIC |
| 213 | CC = qcc -Vgcc_ntoarmv7le |
| 214 | CC_AS = $(CC) |
| 215 | HAVE_NEON = 1 |
| 216 | USE_DYNAREC = 1 |
| 217 | DRC_CACHE_BASE = 0 |
| 218 | BUILTIN_GPU = neon |
| 219 | ARCH = arm |
| 220 | CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp |
| 221 | ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp |
| 222 | MAIN_LDLIBS += -lsocket |
| 223 | LIBPTHREAD := |
| 224 | LIBDL := |
| 225 | LIBM := |
| 226 | |
| 227 | #Raspberry Pi 2 |
| 228 | else ifeq ($(platform), rpi2) |
| 229 | TARGET := $(TARGET_NAME)_libretro.so |
| 230 | fpic := -fPIC |
| 231 | CFLAGS += -marm -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard |
| 232 | ASFLAGS += -mcpu=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard |
| 233 | HAVE_NEON = 1 |
| 234 | ARCH = arm |
| 235 | BUILTIN_GPU = neon |
| 236 | USE_DYNAREC = 1 |
| 237 | |
| 238 | #Raspberry Pi 3 |
| 239 | else ifeq ($(platform), rpi3) |
| 240 | TARGET := $(TARGET_NAME)_libretro.so |
| 241 | fpic := -fPIC |
| 242 | CFLAGS += -marm -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard |
| 243 | ASFLAGS += -mcpu=cortex-a53 -mfpu=neon-fp-armv8 -mfloat-abi=hard |
| 244 | HAVE_NEON = 1 |
| 245 | ARCH = arm |
| 246 | BUILTIN_GPU = neon |
| 247 | USE_DYNAREC = 1 |
| 248 | |
| 249 | # Classic Platforms #################### |
| 250 | # Platform affix = classic_<ISA>_<µARCH> |
| 251 | # Help at https://modmyclassic.com/comp |
| 252 | |
| 253 | # (armv7 a7, hard point, neon based) ### |
| 254 | # NESC, SNESC, C64 mini |
| 255 | else ifeq ($(platform), classic_armv7_a7) |
| 256 | TARGET := $(TARGET_NAME)_libretro.so |
| 257 | fpic := -fPIC |
| 258 | CFLAGS += -Ofast \ |
| 259 | -flto=4 -fwhole-program -fuse-linker-plugin \ |
| 260 | -fdata-sections -ffunction-sections -Wl,--gc-sections \ |
| 261 | -fno-stack-protector -fno-ident -fomit-frame-pointer \ |
| 262 | -falign-functions=1 -falign-jumps=1 -falign-loops=1 \ |
| 263 | -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-unroll-loops \ |
| 264 | -fmerge-all-constants -fno-math-errno \ |
| 265 | -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard |
| 266 | CXXFLAGS += $(CFLAGS) |
| 267 | CPPFLAGS += $(CFLAGS) |
| 268 | ASFLAGS += $(CFLAGS) |
| 269 | HAVE_NEON = 1 |
| 270 | ARCH = arm |
| 271 | BUILTIN_GPU = neon |
| 272 | USE_DYNAREC = 1 |
| 273 | ifeq ($(shell echo `$(CC) -dumpversion` "< 4.9" | bc -l), 1) |
| 274 | CFLAGS += -march=armv7-a |
| 275 | else |
| 276 | CFLAGS += -march=armv7ve |
| 277 | # If gcc is 5.0 or later |
| 278 | ifeq ($(shell echo `$(CC) -dumpversion` ">= 5" | bc -l), 1) |
| 279 | LDFLAGS += -static-libgcc -static-libstdc++ |
| 280 | endif |
| 281 | endif |
| 282 | ####################################### |
| 283 | |
| 284 | # ARM |
| 285 | else ifneq (,$(findstring armv,$(platform))) |
| 286 | TARGET := $(TARGET_NAME)_libretro.so |
| 287 | fpic := -fPIC |
| 288 | DRC_CACHE_BASE = 0 |
| 289 | ifneq (,$(findstring cortexa8,$(platform))) |
| 290 | CFLAGS += -marm -mcpu=cortex-a8 |
| 291 | ASFLAGS += -mcpu=cortex-a8 |
| 292 | else ifneq (,$(findstring cortexa7,$(platform))) |
| 293 | CFLAGS += -marm -mcpu=cortex-a7 |
| 294 | ASFLAGS += -mcpu=cortex-a7 |
| 295 | LIBZ := |
| 296 | else ifneq (,$(findstring cortexa9,$(platform))) |
| 297 | CFLAGS += -marm -mcpu=cortex-a9 |
| 298 | ASFLAGS += -mcpu=cortex-a9 |
| 299 | endif |
| 300 | CFLAGS += -marm |
| 301 | ifneq (,$(findstring neon,$(platform))) |
| 302 | CFLAGS += -mfpu=neon |
| 303 | ASFLAGS += -mfpu=neon |
| 304 | HAVE_NEON = 1 |
| 305 | BUILTIN_GPU = neon |
| 306 | endif |
| 307 | ifneq (,$(findstring softfloat,$(platform))) |
| 308 | CFLAGS += -mfloat-abi=softfp |
| 309 | ASFLAGS += -mfloat-abi=softfp |
| 310 | else ifneq (,$(findstring hardfloat,$(platform))) |
| 311 | CFLAGS += -mfloat-abi=hard |
| 312 | ASFLAGS += -mfloat-abi=hard |
| 313 | endif |
| 314 | ARCH = arm |
| 315 | USE_DYNAREC = 1 |
| 316 | |
| 317 | # Windows |
| 318 | else |
| 319 | TARGET := $(TARGET_NAME)_libretro.dll |
| 320 | BUILTIN_GPU = peops |
| 321 | PLATFORM = libretro |
| 322 | MAIN_LDFLAGS += -static-libgcc -static-libstdc++ -s |
| 323 | CFLAGS += -D__WIN32__ -DNO_DYLIB |
| 324 | MMAP_WIN32=1 |
| 325 | MAIN_LDLIBS += -lws2_32 |
| 326 | LIBPTHREAD := |
| 327 | LIBDL := |
| 328 | LIBM := |
| 329 | endif |
| 330 | |
| 331 | CFLAGS += $(fpic) |
| 332 | MAIN_LDFLAGS += -shared |
| 333 | MAIN_LDLIBS += $(LIBPTHREAD) $(LIBM) $(LIBDL) $(LIBZ) |
| 334 | |
| 335 | # try to autodetect stuff for the lazy |
| 336 | ifndef ARCH |
| 337 | ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}') |
| 338 | endif |
| 339 | ifndef HAVE_NEON |
| 340 | HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0) |
| 341 | endif |
| 342 | ifeq ($(NO_UNDEF_CHECK)$(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU) |
| 343 | MAIN_LDFLAGS += -Wl,--no-undefined |
| 344 | endif |
| 345 | |
| 346 | # try to autodetect stuff for the lazy |
| 347 | ifndef ARCH |
| 348 | ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}') |
| 349 | endif |
| 350 | ifndef HAVE_NEON |
| 351 | HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0) |
| 352 | endif |
| 353 | ifeq ($(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU) |
| 354 | MAIN_LDFLAGS += -Wl,--no-undefined |
| 355 | endif |
| 356 | |
| 357 | TARGET ?= libretro.so |
| 358 | PLATFORM = libretro |
| 359 | BUILTIN_GPU ?= peops |
| 360 | SOUND_DRIVERS = libretro |
| 361 | PLUGINS = |
| 362 | NO_CONFIG_MAK = yes |
| 363 | |
| 364 | # what does this do |
| 365 | #libretro_all: all |
| 366 | #ifeq ($(platform),ios) |
| 367 | #ifeq ($(USE_DYNAREC),1) |
| 368 | # make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) clean |
| 369 | # make -f Makefile.libretro USE_DYNAREC=0 platform=$(platform) |
| 370 | #endif |
| 371 | #endif |
| 372 | |
| 373 | include Makefile |
| 374 | |
| 375 | # no special AS needed for gpu_neon |
| 376 | plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S |
| 377 | $(CC) $(CFLAGS) -c $^ -o $@ |