-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile.common
193 lines (158 loc) · 5.65 KB
/
Makefile.common
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
######################################################################
# Common settings and defaults
######################################################################
# Reset flags (DEFINES not reset as used in Makefile)
INCLUDES :=
OBJS_DEPS :=
OBJS :=
DETECT_OBJS :=
MODULES :=
$(foreach MODULE,$(MODULES),$(MODULE_OBJS-$(MODULE)) :=)
# Defaults
USE_ZLIB ?= 1
USE_TREMOR ?= 0
USE_VORBIS ?= 1
USE_FLAC ?= 1
USE_MAD ?= 1
USE_FAAD ?= 1
USE_PNG ?= 1
USE_JPEG ?= 1
USE_THEORADEC ?= 1
USE_FREETYPE2 ?= 1
HAVE_MT32EMU ?= 1
USE_FLUIDSYNTH ?= 1
USE_LUA ?= 1
USE_LIBCO ?= 1
LOAD_RULES_MK = 1
USE_TINYGL ?= 1
USE_BINK ?= 1
POSIX ?= 1
NO_HIGH_DEF ?= 0
NO_WIP ?= 1
USE_LIBCO ?= 1
ENABLE_VKEYBD = 1
USE_CLOUD ?= 0
STATIC_LINKING ?= 0
LITE ?= 0
# Paths
SCUMMVM_PATH := $(ROOT_PATH)/scummvm
CORE_PATH := $(ROOT_PATH)/src
DEPS_PATH := $(ROOT_PATH)/libretro-deps
LIBRETRO_COMM_PATH := $(ROOT_PATH)/libretro-common
srcdir := $(SCUMMVM_PATH)
VPATH := $(SCUMMVM_PATH)
# Core version shown in frontend
GIT_TAG := $(shell cd $(ROOT_PATH) 2>/dev/null && git describe --tags 2>/dev/null)
ifeq ($(GIT_TAG),)
GIT_HASH := $(shell cd $(ROOT_PATH) 2>/dev/null && git rev-parse --short HEAD 2>/dev/null)
ifneq ($(GIT_HASH),)
DEFINES += -DGIT_HASH=\"$(GIT_HASH)\"
endif
else
DEFINES += -DGIT_TAG=\"$(GIT_TAG)\"
endif
# Nice name shown in frontend
CORE_NAME = "ScummVM"
# Pipe separated allowed file extensions that core can handle
CORE_EXTENSIONS = "scummvm"
INCLUDES += -I$(SCUMMVM_PATH)
DEFINES += -D__LIBRETRO__ -DNONSTANDARD_PORT -DUSE_RGB_COLOR -DUSE_OSD -DDISABLE_TEXT_CONSOLE -DFRONTEND_SUPPORTS_RGB565 -DUSE_TRANSLATION -DDETECTION_STATIC -DHAVE_CONFIG_H -DUSE_BINK -DUSE_LUA -DUSE_TINYGL -DENABLE_VKEYBD
DEFINES += -DCORE_NAME=\"$(CORE_NAME)\" -DCORE_EXTENSIONS=\"$(CORE_EXTENSIONS)\"
ifeq ($(USE_LIBCO), 1)
DEFINES += -DUSE_LIBCO
else
LDFLAGS += -lpthread
endif
ifeq ($(TARGET_64BIT), 1)
DEFINES += -DSIZEOF_SIZE_T=8 -DSCUMM_64BITS
else
DEFINES += -DSIZEOF_SIZE_T=4
endif
######################################################################
# Libretro settings
######################################################################
INCLUDES += -I$(ROOT_PATH)/include
MODULE_PATHS += $(CORE_PATH)
LIBRETRO_OBJS := $(CORE_PATH)/libretro_os.o \
$(CORE_PATH)/libretro-fs.o \
$(CORE_PATH)/libretro-fs-factory.o \
$(CORE_PATH)/libretro.o
ifneq ($(USE_LIBCO), 1)
LIBRETRO_OBJS += $(CORE_PATH)/retro_emu_thread.o
endif
OBJS += $(LIBRETRO_OBJS)
######################################################################
# External dependencies settings
######################################################################
include $(ROOT_PATH)/Makefile.deps
######################################################################
# Module settings
######################################################################
INCLUDES += -I$(SCUMMVM_PATH)/engines -I$(SCUMMVM_PATH)/backends/vkeybd
# Base modules
BASE_MODULES := base
MODULES += $(BASE_MODULES)
# script.mri head
ifeq ($(STATIC_LINKING),1)
$(shell printf "CREATE $(TARGET)\n" > $(ROOT_PATH)/script.mri)
endif
# Engine modules
# Following script
# - generates configuration engines files (build/config.mk.engines, engines/engines.mk, engines/plugins_table.h, engines/detection_table.h) from actual source in $(SCUMMVM_PATH).
# or (if static linking is required)
# - generates config.mk.engines.lite - static file with a reduced set of engines for minimal builds - from lite_engines.list
# - generates script.mri engines part
ifeq (,$(filter clean datafiles coreinfo,$(MAKECMDGOALS)))
$(info Configuring ScummVM engines...)
ifneq ($(shell cd $(ROOT_PATH); ./configure_engines.sh $(NO_HIGH_DEF) $(NO_WIP) $(STATIC_LINKING) $(LITE)),0)
$(error Configuring ScummVM engines failed)
endif
endif
ifeq ($(LITE), 1)
-include $(ROOT_PATH)/config.mk.engines.lite
else
-include $(SCUMMVM_PATH)/config.mk.engines
endif
-include $(SCUMMVM_PATH)/engines/engines.mk
# Shared modules
SHARED_MODULES := \
engines \
gui \
backends \
video \
image \
graphics \
audio \
math \
common
ifeq ($(HAVE_MT32EMU),1)
SHARED_MODULES += audio/softsynth/mt32
INCLUDES += -I$(SCUMMVM_PATH)/audio/softsynth/mt32/sha1
DEFINES += -DUSE_MT32EMU
endif
MODULES += $(SHARED_MODULES)
# script.mri tail
ifeq ($(STATIC_LINKING),1)
$(shell printf "$(addprefix ADDLIB libtemp/lib, $(addsuffix .a\n,$(notdir $(BASE_MODULES) $(SHARED_MODULES))))" >> $(ROOT_PATH)/script.mri)
$(shell printf "ADDLIB libtemp/libdeps.a\n" >> $(ROOT_PATH)/script.mri)
$(shell printf "ADDLIB libtemp/libdetect.a\n" >> $(ROOT_PATH)/script.mri)
$(shell printf "$(addprefix ADDMOD libtemp/, $(addsuffix \n,$(notdir $(LIBRETRO_OBJS))))" >> $(ROOT_PATH)/script.mri)
$(shell printf "SAVE\n" >> $(ROOT_PATH)/script.mri)
$(shell printf "END\n" >> $(ROOT_PATH)/script.mri)
$(shell sed -i.bak -e "s/^ //g" $(ROOT_PATH)/script.mri;rm -f $(ROOT_PATH)/script.mri.bak)
endif
######################################################################
# Rules
######################################################################
core: $(TARGET)
datafiles: scummvm.zip
coreinfo: $(TARGET_NAME)_libretro.info
all: $(TARGET) scummvm.zip $(TARGET_NAME)_libretro.info
#bundle_files
scummvm.zip: $(SCUMMVM_PATH)/dists/scummvm.rc
@echo Preparing $@
@cd $(ROOT_PATH); ./bundle_datafiles.sh bundle $(TARGET_NAME)
$(TARGET_NAME)_libretro.info: $(SCUMMVM_PATH)/dists/scummvm.rc
@echo Preparing $@
@cd $(ROOT_PATH); ./bundle_datafiles.sh info $(TARGET_NAME) $(CORE_NAME) $(CORE_EXTENSIONS)
.PHONY: all core datafiles coreinfo