forked from libretro/ep128emu-core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
198 lines (174 loc) · 4.89 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
TARGET_NAME := ep128emu_core
EXCLUDE_SOUND_LIBS ?= 1
STATIC_LINKING := 0
DEBUG = 0
LIBS :=
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
else ifneq ($(findstring armv,$(shell uname -a)),)
platform = armv
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
ifeq ($(shell uname -p),arm)
arch = arm
endif
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
# Unix
ifeq ($(platform), unix)
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,-version-script=link.T -Wl,-no-undefined
CC ?= gcc
CXX ?= g++
LDFLAGS += -Wl,--as-needed
else ifneq (,$(findstring linux-portable,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC -nostdlib
LIBM :=
SHARED := -shared -Wl,-version-script=link.T
LDFLAGS += -Wl,--as-needed
# ARM
else ifneq (,$(findstring armv,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
fpic := -fPIC
SHARED := -shared -Wl,-version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++
ifneq (,$(findstring cortexa8,$(platform)))
PLATFORM_DEFINES += -marm -mcpu=cortex-a8
else ifneq (,$(findstring cortexa9,$(platform)))
PLATFORM_DEFINES += -marm -mcpu=cortex-a9
endif
PLATFORM_DEFINES += -marm
PLATFORM_DEFINES += -mtune=generic-armv7-a -mhard-float
LDFLAGS += -Wl,--as-needed
# OS X
else ifeq ($(platform), osx)
TARGET := $(TARGET_NAME)_libretro.dylib
fpic := -fPIC
SHARED := -dynamiclib
MINVERSION :=
OSXVER = `sw_vers -productVersion | cut -d. -f 2`
OSX_LT_MAVERICKS = `(( $(OSXVER) <= 9)) && echo "YES"`
ifeq ($(OSX_LT_MAVERICKS),"YES")
MINVERSION = -mmacosx-version-min=10.5
endif
fpic += $(MINVERSION)
ifeq ($(CROSS_COMPILE),1)
TARGET_RULE = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT)
CFLAGS += $(TARGET_RULE)
CPPFLAGS += $(TARGET_RULE)
CXXFLAGS += $(TARGET_RULE)
LDFLAGS += $(TARGET_RULE)
endif
CFLAGS += $(ARCHFLAGS)
CXXFLAGS += $(ARCHFLAGS)
LDFLAGS += $(ARCHFLAGS)
# Windows cross-compilation
# If variables are set up externally by buildbot, do not override.
else ifeq ($(platform), win64)
TARGET := $(TARGET_NAME)_libretro.dll
ifeq ($(findstring mingw,$(AR)),)
AR = x86_64-w64-mingw32-ar
endif
ifeq ($(findstring mingw,$(CC)),)
CC = x86_64-w64-mingw32-gcc
endif
ifeq ($(findstring mingw,$(CXX)),)
CXX = x86_64-w64-mingw32-g++
endif
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++
LDFLAGS += -lwinmm -Wl,--export-all-symbols
LDFLAGS += -Wl,--as-needed
else ifeq ($(platform), win32)
TARGET := $(TARGET_NAME)_libretro.dll
ifeq ($(findstring mingw,$(AR)),)
AR = i686-w64-mingw32-ar
endif
ifeq ($(findstring mingw,$(CC)),)
CC = i686-w64-mingw32-gcc
endif
ifeq ($(findstring mingw,$(CXX)),)
CXX = i686-w64-mingw32-g++
endif
SHARED := -shared -Wl,--no-undefined -Wl,--version-script=link.T
LDFLAGS += -static-libgcc -static-libstdc++ -L. -m32
LDFLAGS += -lwinmm -Wl,--export-all-symbols
LDFLAGS += -Wl,--as-needed
PLATFORM_DEFINES += -march=pentium2
CFLAGS += -m32
CXXFLAGS += -m32
# emscripten
else ifeq ($(platform), emscripten)
TARGET := $(TARGET_NAME)_libretro_$(platform).bc
SHARED := -shared -s TOTAL_MEMORY=184842208
STATIC_LINKING=1
endif
ifeq ($(STATIC_LINKING), 1)
EXT := a
endif
LIBM = -lpthread
ifeq ($(EXCLUDE_SOUND_LIBS), 0)
LIBM += -lsndfile
endif
LDFLAGS += $(LIBM)
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
else
CFLAGS += -O3 -fno-inline-functions -fomit-frame-pointer -ffast-math
CXXFLAGS += -O3 -fno-inline-functions -fomit-frame-pointer -ffast-math
LDFLAGS += -s
endif
DEFINES := $(PLATFORM_DEFINES) -DEP128EMU_LIBRETRO_CORE
ifeq ($(EXCLUDE_SOUND_LIBS), 1)
DEFINES += -DEXCLUDE_SOUND_LIBS
endif
# DEFINES += -DEP128EMU_USE_XRGB8888
CFLAGS += $(DEFINES)
CXXFLAGS += $(DEFINES) -std=c++0x
include Makefile.common
INCLUDES := $(INCFLAGS)
OBJECTS := $(SOURCES_CPP:.cpp=.o)
OBJECTS += $(SOURCES_C:.c=.o)
CFLAGS += -Wall $(fpic)
CXXFLAGS += -Wall $(fpic)
all Release: $(TARGET)
$(TARGET): $(OBJECTS)
ifeq ($(STATIC_LINKING), 1)
$(AR) rcs $@ $(OBJECTS)
else
$(CXX) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS)
#@$(CC) -o $@ $(SHARED) $(OBJS) $(LDFLAGS) $(LIBS)
endif
%.o: %.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) $(fpic) -c -o $@ $<
#$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) $(fpic) -c -o $@ $<
#@echo $@
#@$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
clean cleanRelease:
rm -f $(OBJECTS) $(TARGET)
.PHONY: clean