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