-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
224 lines (202 loc) · 6.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
GX_PTHREAD_LEGACY := 1
STATIC_LINKING := 0
AR := ar
ifeq ($(platform),)
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
endif
endif
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
TARGET_NAME := zc210
LIBM= -lm
ifeq ($(ARCHFLAGS),)
ifeq ($(archs),ppc)
ARCHFLAGS = -arch ppc -arch ppc64
else
ARCHFLAGS = -arch i386 -arch x86_64
endif
endif
ifeq ($(platform), osx)
ifndef ($(NOUNIVERSAL))
CFLAGS += $(ARCHFLAGS)
LFLAGS += $(ARCHFLAGS)
endif
endif
ifeq ($(STATIC_LINKING), 1)
EXT := a
endif
ifeq ($(platform), unix)
EXT ?= so
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
LDFLAGS := -lpthread
else ifeq ($(platform), linux-portable)
TARGET := $(TARGET_NAME)_libretro.$(EXT)
fpic := -fPIC -nostdlib
SHARED := -shared -Wl,--version-script=link.T
LIBM :=
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
else ifneq (,$(findstring ios,$(platform)))
TARGET := $(TARGET_NAME)_libretro_ios.dylib
fpic := -fPIC
SHARED := -dynamiclib
ifeq ($(IOSSDK),)
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
endif
DEFINES := -DIOS
ifeq ($(platform), ios-arm64)
CC = cc -arch arm64 -isysroot $(IOSSDK)
else
CC = cc -arch armv7 -isysroot $(IOSSDK)
endif
ifeq ($(platform),$(filter $(platform),ios9 ios-arm64))
CC += -miphoneos-version-min=8.0
CFLAGS += -miphoneos-version-min=8.0
else
CC += -miphoneos-version-min=5.0
CFLAGS += -miphoneos-version-min=5.0
endif
else ifneq (,$(findstring qnx,$(platform)))
TARGET := $(TARGET_NAME)_libretro_qnx.so
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
fpic := -fPIC
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
else ifeq ($(platform), vita)
TARGET := $(TARGET_NAME)_libretro_vita.a
CC = arm-vita-eabi-gcc
AR = arm-vita-eabi-ar
CFLAGS += -Wl,-q -Wall -O3
STATIC_LINKING = 1
# CTR (3DS)
else ifeq ($(platform), ctr)
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITARM)/bin/arm-none-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT)
AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT)
CFLAGS += -D_3DS -DARM11 -march=armv6k -mtune=mpcore -mfloat-abi=hard
STATIC_LINKING = 1
# Nintendo Switch (libnx)
else ifeq ($(platform), libnx)
include $(DEVKITPRO)/libnx/switch_rules
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
DEFINES := -DSWITCH=1 -D__SWITCH__=1 -DHAVE_LIBNX=1
CFLAGS := $(DEFINES) -g -fPIE -I$(LIBNX)/include/ -I$(PORTLIBS)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec
CFLAGS += $(INCDIRS) -I$(CORE_DIR)/zlib -I$(CORE_DIR)/libogg/include -I$(CORE_DIR)/libvorbis/include \
-I$(CORE_DIR)/jpeg-8c -fvisibility=hidden
CFLAGS += -march=armv8-a -mtune=cortex-a57 -mtp=soft -mcpu=cortex-a57+crc+fp+simd -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp
STATIC_LINKING = 1
else ifeq ($(platform), psp1)
TARGET := $(TARGET_NAME)_libretro_psp1.a
CC = psp-gcc
CXX = psp-g++
AR = psp-ar
CFLAGS += -DPSP -G0
CXXFLAGS += -DPSP -G0
DISABLE_ADLIB = 1
CFLAGS += -I$(shell psp-config --pspsdk-path)/include
STATIC_LINKING = 1
else ifeq ($(platform), ps2)
TARGET := $(TARGET_NAME)_libretro_ps2.a
CC = ee-gcc
CXX = ee-g++
AR = ee-ar
CFLAGS += -DPS2 -G0 -D__sun
CXXFLAGS += -DPS2 -G0 -D__sun
STATIC_LINKING = 1
else ifeq ($(platform), psl1ght)
EXT=a
TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
CC = $(PS3DEV)/ppu/bin/ppu-gcc$(EXE_EXT)
CXX = $(PS3DEV)/ppu/bin/ppu-g++$(EXE_EXT)
AR = $(PS3DEV)/ppu/bin/ppu-ar$(EXE_EXT)
CFLAGS += -D__ppc__ -D__CELLOS_LV2__ -D__PSL1GHT__ -I$(PSL1GHT)/ppu/include
STATIC_LINKING = 1
else ifneq (,$(filter $(platform), ngc wii wiiu))
TARGET := $(TARGET_NAME)_libretro_$(platform).a
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
FLAGS += -DGEKKO -mcpu=750 -meabi -mhard-float -malign-natural
FLAGS += -fsingle-precision-constant -mno-bit-align
FLAGS += -DHAVE_STRTOUL
FLAGS += -I$(DEVKITPRO)/libogc/include
ENDIANNESS_DEFINES = -DMSB_FIRST
ifneq (,$(findstring wiiu,$(platform)))
FLAGS += -DWIIU -DHW_RVL -mwup
else ifneq (,$(findstring wii,$(platform)))
FLAGS += -DHW_RVL -mrvl
else ifneq (,$(findstring ngc,$(platform)))
FLAGS += -DHW_DOL -mogc
endif
CFLAGS += $(FLAGS)
CXXFLAGS += $(FLAGS) -fno-merge-constants
STATIC_LINKING = 1
ifeq ($(GX_PTHREAD_LEGACY), 1)
CFLAGS += -DGX_PTHREAD_LEGACY
CXXFLAGS += -DGX_PTHREAD_LEGACY
endif
else
CC = gcc
TARGET := $(TARGET_NAME)_libretro.dll
SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined
endif
LDFLAGS += $(LIBM)
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
else
CFLAGS += -O3
CXXFLAGS += -O3
endif
CORE_DIR := .
include Makefile.common
OBJECTS := $(SOURCES_CXX:.cpp=.o) $(SOURCES_C:.c=.o)
CFLAGS += -Wall -pedantic $(ENDIANNESS_DEFINES)
CXXFLAGS += -Wall -pedantic -std=gnu++11 $(ENDIANNESS_DEFINES)
ifneq (,$(findstring qnx,$(platform)))
CFLAGS += -Wc,-std=c99
else
CFLAGS += -std=gnu99
endif
all: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
$(CXX) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS)
endif
%.o: %.c
$(CC) $(INCFLAGS) $(CFLAGS) $(fpic) -c -o $@ $<
%.o: %.cpp
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(fpic) -c -o $@ $<
clean:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean