drc: try to support w^x platforms like iOS
[pcsx_rearmed.git] / Makefile.libretro
CommitLineData
706252fc 1# Makefile for PCSX ReARMed (libretro)
2
1c6ab616 3ifeq ($(platform),)
fb01e82a 4 platform = unix
5 ifeq ($(shell uname -a),)
6 platform = win
7 else ifneq ($(findstring MINGW,$(shell uname -a)),)
8 platform = win
9 else ifneq ($(findstring Darwin,$(shell uname -a)),)
10 platform = osx
11 else ifneq ($(findstring win,$(shell uname -a)),)
12 platform = win
13 endif
1c6ab616 14endif
15
a4874585
C
16CC ?= gcc
17CXX ?= g++
18AS ?= as
8ad07683 19CC_AS ?= $(CC)
b09a1d34 20CFLAGS ?=
1c6ab616 21
468564e2 22TARGET_NAME := pcsx_rearmed
23
ce0e7ac9 24MMAP_WIN32=0
25
fb01e82a 26# Unix
1c6ab616 27ifeq ($(platform), unix)
fb01e82a 28 TARGET := $(TARGET_NAME)_libretro.so
29 fpic := -fPIC
30 SHARED := -shared -Wl,--version-script=libretro/link.T
31
32# OS X
1c6ab616 33else ifeq ($(platform), osx)
fb01e82a 34 TARGET := $(TARGET_NAME)_libretro.dylib
35 fpic := -fPIC
36 SHARED := -dynamiclib
37 OSXVER = `sw_vers -productVersion | cut -d. -f 2`
38 OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
39 ifeq ($(OSX_LT_MAVERICKS),"YES")
40 fpic += -mmacosx-version-min=10.5
41 endif
42
43# iOS
1c6ab616 44else ifeq ($(platform), ios)
fb01e82a 45 ARCH := arm
46 TARGET := $(TARGET_NAME)_libretro_ios.dylib
47 fpic := -fPIC
48 SHARED := -dynamiclib
1c6ab616 49
fb01e82a 50 ifeq ($(IOSSDK),)
51 IOSSDK := $(shell xcrun -sdk iphoneos -show-sdk-path)
52 endif
ac86f051 53
fb01e82a 54 CC = clang -arch armv7 -isysroot $(IOSSDK)
55 CXX = clang++ -arch armv7 -isysroot $(IOSSDK)
56 CC_AS = perl ./tools/gas-preprocessor.pl $(CC)
57 CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -marm
58 ASFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon
59 HAVE_NEON = 1
60 BUILTIN_GPU = neon
61 USE_DYNAREC = 1
62 CFLAGS += -DIOS
63 OSXVER = `sw_vers -productVersion | cut -d. -f 2`
64 OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
65 ifeq ($(OSX_LT_MAVERICKS),"YES")
66 CC += -miphoneos-version-min=5.0
67 CXX += -miphoneos-version-min=5.0
68 CC_AS += -miphoneos-version-min=5.0
69 CFLAGS += -miphoneos-version-min=5.0
70 endif
71
72# PS3
1c6ab616 73else ifeq ($(platform), ps3)
fb01e82a 74 TARGET := $(TARGET_NAME)_libretro_ps3.a
75 CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
76 AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe
77 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
78
79# sncps3
1c6ab616 80else ifeq ($(platform), sncps3)
fb01e82a 81 TARGET := $(TARGET_NAME)_libretro_ps3.a
82 CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
83 AR = $(CELL_SDK)/host-win32/sn/bin/ps3snarl.exe
84 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
85
86# Lightweight PS3 Homebrew SDK
1c6ab616 87else ifeq ($(platform), psl1ght)
fb01e82a 88 TARGET := $(TARGET_NAME)_libretro_psl1ght.a
89 CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
90 AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
91 CFLAGS += -DBLARGG_BIG_ENDIAN=1 -D__ppc__
92
93# PSP
1c6ab616 94else ifeq ($(platform), psp1)
93305561 95 TARGET := $(TARGET_NAME)_libretro_psp1.a
1c6ab616 96 CC = psp-gcc$(EXE_EXT)
97 AR = psp-ar$(EXE_EXT)
98 CFLAGS += -DPSP -G0
fb01e82a 99
100# Xbox 360
1c6ab616 101else ifeq ($(platform), xenon)
fb01e82a 102 TARGET := $(TARGET_NAME)_libretro_xenon360.a
103 CC = xenon-gcc$(EXE_EXT)
104 AR = xenon-ar$(EXE_EXT)
105 CFLAGS += -D__LIBXENON__ -m32 -D__ppc__
106
107# Nintendo Game Cube
1c6ab616 108else ifeq ($(platform), ngc)
fb01e82a 109 TARGET := $(TARGET_NAME)_libretro_ngc.a
110 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
111 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
112 CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
113
114# Nintendo Wii
1c6ab616 115else ifeq ($(platform), wii)
fb01e82a 116 TARGET := libretro_$(TARGET_NAME)_wii.a
117 CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
118 AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
119 CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -DBLARGG_BIG_ENDIAN=1 -D__ppc__
120
121# QNX
a4874585 122else ifeq ($(platform), qnx)
fb01e82a 123 TARGET := $(TARGET_NAME)_libretro_qnx.so
124 CC = qcc -Vgcc_ntoarmv7le
125 CC_AS = $(CC)
126 HAVE_NEON = 1
127 USE_DYNAREC = 1
128 DRC_CACHE_BASE = 0
129 BUILTIN_GPU = neon
130 ARCH = arm
131 CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp
132 ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp
133
134# ARM
1af4c281 135else ifneq (,$(findstring armv,$(platform)))
fb01e82a 136 TARGET := $(TARGET_NAME)_libretro.so
137 SHARED := -shared -Wl,--no-undefined
138 DRC_CACHE_BASE = 0
139 ifneq (,$(findstring cortexa8,$(platform)))
140 CFLAGS += -marm -mcpu=cortex-a8
141 ASFLAGS += -mcpu=cortex-a8
142 else ifneq (,$(findstring cortexa9,$(platform)))
143 CFLAGS += -marm -mcpu=cortex-a9
144 ASFLAGS += -mcpu=cortex-a9
145 endif
146 CFLAGS += -marm
147 ifneq (,$(findstring neon,$(platform)))
148 CFLAGS += -mfpu=neon
149 ASFLAGS += -mfpu=neon
150 HAVE_NEON = 1
151 BUILTIN_GPU = neon
152 endif
153 ifneq (,$(findstring softfloat,$(platform)))
154 CFLAGS += -mfloat-abi=softfp
155 ASFLAGS += -mfloat-abi=softfp
156 else ifneq (,$(findstring hardfloat,$(platform)))
157 CFLAGS += -mfloat-abi=hard
158 ASFLAGS += -mfloat-abi=hard
159 endif
160 ARCH = arm
161 USE_DYNAREC = 1
162
163# Windows
1c6ab616 164else
fb01e82a 165 TARGET := $(TARGET_NAME)_libretro.dll
166 CC = gcc
167 fpic := -fPIC
168 LD_FLAGS := -fPIC
169 SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=libretro/link.T
170 CFLAGS += -D__WIN32__ -D__WIN32_LIBRETRO__
171 MMAP_WIN32=1
1c6ab616 172endif
173
9aff1963 174CFLAGS += -fPIC
003cfc63 175ifeq ($(platform),win)
176 MAIN_LDLIBS += -lws2_32
177else ifneq ($(platform),qnx)
fb01e82a 178 LDLIBS += -lpthread
179 MAIN_LDLIBS += -ldl
a4874585 180endif
9aff1963 181MAIN_LDFLAGS += -shared
a4874585 182MAIN_LDLIBS += -lm -lz
9aff1963 183EXTRA_LDFLAGS =
706252fc 184
e230dbf6 185# try to autodetect stuff for the lazy
186ifndef ARCH
187ARCH = $(shell $(CC) -dumpmachine | awk -F- '{print $$1}')
188endif
189ifndef HAVE_NEON
190HAVE_NEON = $(shell $(CC) -E -dD - < /dev/null 2> /dev/null | grep -q __ARM_NEON__ && echo 1 || echo 0)
191endif
192ifeq ($(shell ld -v 2> /dev/null | awk '{print $$1}'),GNU)
193MAIN_LDFLAGS += -Wl,--no-undefined
194endif
195
a4874585 196TARGET ?= libretro.so
706252fc 197PLATFORM = libretro
a4874585 198BUILTIN_GPU ?= peops
706252fc 199SOUND_DRIVERS = libretro
9aff1963 200PLUGINS =
201NO_CONFIG_MAK = yes
706252fc 202
9aff1963 203include Makefile
cd230693 204
af32009f 205# no special AS needed for gpu_neon
206plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.o: plugins/gpu_neon/psx_gpu/psx_gpu_arm_neon.S
207 $(CC) $(CFLAGS) -c $^ -o $@