1##LIBRETRO
2DEBUG=0
3USE_ZLIB   = 1
4USE_TREMOR = 0
5USE_VORBIS = 1
6USE_FLAC   = 1
7USE_MAD    = 1
8USE_FAAD   = 1
9USE_PNG    = 1
10USE_JPEG   = 1
11USE_THEORADEC=1
12USE_FREETYPE2=1
13HAVE_MT32EMU=1
14USE_FLUIDSYNTH=1
15USE_LUA    = 1
16
17HIDE := @
18SPACE :=
19SPACE := $(SPACE) $(SPACE)
20BACKSLASH :=
21BACKSLASH := \$(BACKSLASH)
22filter_out1 = $(filter-out $(firstword $1),$1)
23filter_out2 = $(call filter_out1,$(call filter_out1,$1))
24unixpath = $(subst \,/,$1)
25unixcygpath = /$(subst :,,$(call unixpath,$1))
26
27ifeq ($(platform),)
28platform = unix
29ifeq ($(shell uname -a),)
30   platform = win
31else ifneq ($(findstring MINGW,$(shell uname -a)),)
32   platform = win
33else ifneq ($(findstring Darwin,$(shell uname -a)),)
34   platform = osx
35	arch = intel
36ifeq ($(shell uname -p),powerpc)
37	arch = ppc
38endif
39else ifneq ($(findstring win,$(shell uname -a)),)
40   platform = win
41endif
42endif
43
44ifeq ($(shell uname -a),)
45   EXE_EXT = .exe
46endif
47
48TARGET_NAME := scummvm
49GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
50ifneq ($(GIT_VERSION)," unknown")
51	CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
52endif
53
54TARGET_64BIT = 0
55ifeq ($(shell uname -m), x86_64)
56   BUILD_64BIT = 1
57else
58   BUILD_64BIT = 0
59endif
60
61LD        = $(CXX)
62AR        = ar cru
63RANLIB    = ranlib
64
65ifeq ($(platform), unix)
66   TARGET  := $(TARGET_NAME)_libretro.so
67   DEFINES += -fPIC
68   LDFLAGS += -shared -Wl,--version-script=../link.T -fPIC
69   TARGET_64BIT := $(BUILD_64BIT)
70# OS X
71else ifeq ($(platform), osx)
72   TARGET  := $(TARGET_NAME)_libretro.dylib
73   DEFINES += -fPIC
74   LDFLAGS += -dynamiclib -fPIC
75ifneq ($(shell uname -p),powerpc)
76   arch = intel
77   TARGET_64BIT := $(BUILD_64BIT)
78else
79   arch = ppc
80endif
81
82# iOS
83else ifeq ($(platform),ios-arm64)
84	CC       = clang -arch arm64 -isysroot $(IOSSDK) -marm
85	CXX      = clang++ -arch armv7 -isysroot $(IOSSDK) -marm
86	CFLAGS += -Wno-error=implicit-function-declaration
87	CC      += -miphoneos-version-min=8.0
88	CXX     += -miphoneos-version-min=8.0
89	TARGET  := $(TARGET_NAME)_libretro_ios.dylib
90	DEFINES += -fPIC -DHAVE_POSIX_MEMALIGN=1 -DIOS
91	LDFLAGS += -dynamiclib -fPIC
92
93else ifneq (,$(findstring ios,$(platform)))
94   TARGET  := $(TARGET_NAME)_libretro_ios.dylib
95   DEFINES += -fPIC -DHAVE_POSIX_MEMALIGN=1 -DIOS
96   LDFLAGS += -dynamiclib -fPIC
97
98ifeq ($(IOSSDK),)
99   IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
100endif
101
102   CC       = clang -arch armv7 -isysroot $(IOSSDK) -marm
103   CXX      = clang++ -arch armv7 -isysroot $(IOSSDK) -marm
104
105ifeq ($(platform),ios9)
106	CC      += -miphoneos-version-min=8.0
107	CXX     += -miphoneos-version-min=8.0
108else
109	CC      += -miphoneos-version-min=5.0
110	CXX     += -miphoneos-version-min=5.0
111endif
112
113# QNX
114else ifeq ($(platform), qnx)
115   TARGET  := $(TARGET_NAME)_libretro_$(platform).so
116   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE
117   LDFLAGS += -shared -Wl,--version-script=../link.T -fPIC
118   CC = qcc -Vgcc_ntoarmv7le
119   CXX = QCC -Vgcc_ntoarmv7le
120   LD = QCC -Vgcc_ntoarmv7le
121   AR = qcc -Vgcc_ntoarmv7le -A
122   RANLIB="${QNX_HOST}/usr/bin/ntoarmv7-ranlib"
123
124# Genode
125else ifeq ($(platform), genode)
126   TARGET  := libretro.so
127   TARGET_64BIT := $(BUILD_64BIT)
128   DEFINES += -fPIC -DSYSTEM_NOT_SUPPORTING_D_TYPE -DFRONTEND_SUPPORTS_RGB565
129   C_PKGS   = libc
130   CXX_PKGS = stdcxx genode-base
131   CFLAGS   += -D__GENODE__ $(shell pkg-config --cflags $(C_PKGS))
132   CXXFLAGS += -D__GENODE__ $(shell pkg-config --cflags $(CXX_PKGS))
133
134   LIBS += $(shell pkg-config --libs $(C_PKGS) $(CXX_PKGS) genode-lib)
135
136   CC  = $(shell pkg-config genode-base --variable=cc)
137   CXX = $(shell pkg-config genode-base --variable=cxx)
138   LD  = $(shell pkg-config genode-base --variable=ld)
139   AR  = $(shell pkg-config genode-base --variable=ar) rcs
140   RANLIB = genode-x86-ranlib
141
142# PS3
143else ifeq ($(platform), ps3)
144   TARGET  := $(TARGET_NAME)_libretro_$(platform).a
145   CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
146   CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
147   AR = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ar.exe rcs
148   DEFINES += -DPLAYSTATION3
149	STATIC_LINKING=1
150
151# Nintendo Wii
152else ifeq ($(platform), wii)
153   TARGET := $(TARGET_NAME)_libretro_wii.a
154   CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
155   CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
156   AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) rcs
157   DEFINES += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -D__ppc__ -I$(DEVKITPRO)/libogc/include
158	STATIC_LINKING=1
159
160# Nintendo Switch (libnx)
161else ifeq ($(platform), libnx)
162    export DEPSDIR := $(CURDIR)
163    include $(DEVKITPRO)/libnx/switch_rules
164    EXT=a
165    TARGET := $(TARGET_NAME)_libretro_$(platform).$(EXT)
166    DEFINES := -DSWITCH=1 -U__linux__ -U__linux
167    DEFINES	+= -g -O3 -fPIE -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec
168    DEFINES += $(INCDIRS)
169    DEFINES += -D__SWITCH__ -DHAVE_LIBNX -march=armv8-a -mtune=cortex-a57 -mtp=soft
170    DEFINES += -I../libretro-common/include
171    CXXFLAGS := $(ASFLAGS) -std=gnu++11 -fpermissive
172    STATIC_LINKING = 1
173
174# Nintendo Wii U
175else ifeq ($(platform), wiiu)
176   TARGET := $(TARGET_NAME)_libretro_wiiu.a
177   CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
178   CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
179   AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) rcs
180   AR_ALONE = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT)
181   DEFINES += -DGEKKO -mwup -mcpu=750 -meabi -mhard-float -D__POWERPC__ -D__ppc__ -DWORDS_BIGENDIAN=1 -DMSB_FIRST
182   DEFINES += -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int -fpermissive
183   DEFINES += -DHAVE_STRTOUL -DWIIU -I../libretro-common/include
184   LITE := 1
185   CP := cp
186# Vita
187else ifeq ($(platform), vita)
188	TARGET := $(TARGET_NAME)_libretro_$(platform).a
189	CC = arm-vita-eabi-gcc$(EXE_EXT)
190	CXX = arm-vita-eabi-g++$(EXE_EXT)
191	AR = arm-vita-eabi-ar$(EXE_EXT) rcs
192	DEFINES += -DVITA
193	STATIC_LINKING = 1
194
195else ifeq ($(platform), android-armv7)
196   TARGET  := $(TARGET_NAME)_libretro_android.so
197   DEFINES += -fPIC -Wno-multichar -D_ARM_ASSEM_
198   LDFLAGS += -shared -Wl,--version-script=../link.T -fPIC
199   TOOLSET = arm-linux-androideabi-
200   USE_VORBIS = 0
201   USE_THEORADEC = 0
202   USE_TREMOR = 1
203   HAVE_MT32EMU = 0
204else ifneq (,$(findstring armv,$(platform)))
205   TARGET := $(TARGET_NAME)_libretro.so
206   DEFINES += -fPIC -Wno-multichar -D_ARM_ASSEM_
207   LDFLAGS += -shared -Wl,--version-script=../link.T -fPIC
208   USE_VORBIS = 0
209   USE_THEORADEC = 0
210   USE_TREMOR = 1
211   HAVE_MT32EMU = 0
212ifneq (,$(findstring cortexa8,$(platform)))
213   DEFINES += -marm -mcpu=cortex-a8
214else ifneq (,$(findstring cortexa9,$(platform)))
215   DEFINES += -marm -mcpu=cortex-a9
216endif
217   DEFINES += -marm
218ifneq (,$(findstring neon,$(platform)))
219   DEFINES += -mfpu=neon
220   HAVE_NEON = 1
221endif
222ifneq (,$(findstring softfloat,$(platform)))
223   DEFINES += -mfloat-abi=softfp
224else ifneq (,$(findstring hardfloat,$(platform)))
225   DEFINES += -mfloat-abi=hard
226endif
227   DEFINES += -DARM
228
229# Emscripten
230else ifeq ($(platform), emscripten)
231	TARGET := $(TARGET_NAME)_libretro_$(platform).bc
232	STATIC_LINKING = 1
233
234# Windows MSVC 2017 all architectures
235else ifneq (,$(findstring windows_msvc2017,$(platform)))
236
237    NO_GCC := 1
238    CFLAGS += -DNOMINMAX
239    CXXFLAGS += -DNOMINMAX
240    WINDOWS_VERSION = 1
241
242	PlatformSuffix = $(subst windows_msvc2017_,,$(platform))
243	ifneq (,$(findstring desktop,$(PlatformSuffix)))
244		WinPartition = desktop
245		MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -FS
246		LDFLAGS += -MANIFEST -LTCG:incremental -NXCOMPAT -DYNAMICBASE -DEBUG -OPT:REF -INCREMENTAL:NO -SUBSYSTEM:WINDOWS -MANIFESTUAC:"level='asInvoker' uiAccess='false'" -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1
247		LIBS += kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
248	else ifneq (,$(findstring uwp,$(PlatformSuffix)))
249		WinPartition = uwp
250		MSVC2017CompileFlags = -DWINAPI_FAMILY=WINAPI_FAMILY_APP -D_WINDLL -D_UNICODE -DUNICODE -D__WRL_NO_DEFAULT_LIB__ -EHsc -FS
251		LDFLAGS += -APPCONTAINER -NXCOMPAT -DYNAMICBASE -MANIFEST:NO -LTCG -OPT:REF -SUBSYSTEM:CONSOLE -MANIFESTUAC:NO -OPT:ICF -ERRORREPORT:PROMPT -NOLOGO -TLBID:1 -DEBUG:FULL -WINMD:NO
252		LIBS += WindowsApp.lib
253	endif
254
255	CFLAGS += $(MSVC2017CompileFlags)
256	CXXFLAGS += $(MSVC2017CompileFlags)
257
258	TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix))
259
260	CC  = cl.exe
261	CXX = cl.exe
262	LD = link.exe
263
264	reg_query = $(call filter_out2,$(subst $2,,$(shell reg query "$2" -v "$1" 2>nul)))
265	fix_path = $(subst $(SPACE),\ ,$(subst \,/,$1))
266
267	ProgramFiles86w := $(shell cmd /c "echo %PROGRAMFILES(x86)%")
268	ProgramFiles86 := $(shell cygpath "$(ProgramFiles86w)")
269
270	WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
271	WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0)
272	WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
273	WindowsSdkDir ?= $(call reg_query,InstallationFolder,HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0)
274	WindowsSdkDir := $(WindowsSdkDir)
275
276	WindowsSDKVersion ?= $(firstword $(foreach folder,$(subst $(subst \,/,$(WindowsSdkDir)Include/),,$(wildcard $(call fix_path,$(WindowsSdkDir)Include\*))),$(if $(wildcard $(call fix_path,$(WindowsSdkDir)Include/$(folder)/um/Windows.h)),$(folder),)))$(BACKSLASH)
277	WindowsSDKVersion := $(WindowsSDKVersion)
278
279	VsInstallBuildTools = $(ProgramFiles86)/Microsoft Visual Studio/2017/BuildTools
280	VsInstallEnterprise = $(ProgramFiles86)/Microsoft Visual Studio/2017/Enterprise
281	VsInstallProfessional = $(ProgramFiles86)/Microsoft Visual Studio/2017/Professional
282	VsInstallCommunity = $(ProgramFiles86)/Microsoft Visual Studio/2017/Community
283
284	VsInstallRoot ?= $(shell if [ -d "$(VsInstallBuildTools)" ]; then echo "$(VsInstallBuildTools)"; fi)
285	ifeq ($(VsInstallRoot), )
286		VsInstallRoot = $(shell if [ -d "$(VsInstallEnterprise)" ]; then echo "$(VsInstallEnterprise)"; fi)
287	endif
288	ifeq ($(VsInstallRoot), )
289		VsInstallRoot = $(shell if [ -d "$(VsInstallProfessional)" ]; then echo "$(VsInstallProfessional)"; fi)
290	endif
291	ifeq ($(VsInstallRoot), )
292		VsInstallRoot = $(shell if [ -d "$(VsInstallCommunity)" ]; then echo "$(VsInstallCommunity)"; fi)
293	endif
294	VsInstallRoot := $(VsInstallRoot)
295
296	VcCompilerToolsVer := $(shell cat "$(VsInstallRoot)/VC/Auxiliary/Build/Microsoft.VCToolsVersion.default.txt" | grep -o '[0-9\.]*')
297	VcCompilerToolsDir := $(VsInstallRoot)/VC/Tools/MSVC/$(VcCompilerToolsVer)
298
299	WindowsSDKSharedIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\shared")
300	WindowsSDKUCRTIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\ucrt")
301	WindowsSDKUMIncludeDir := $(shell cygpath -w "$(WindowsSdkDir)\Include\$(WindowsSDKVersion)\um")
302	WindowsSDKUCRTLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\ucrt\$(TargetArchMoniker)")
303	WindowsSDKUMLibDir := $(shell cygpath -w "$(WindowsSdkDir)\Lib\$(WindowsSDKVersion)\um\$(TargetArchMoniker)")
304
305	# For some reason the HostX86 compiler doesn't like compiling for x64
306	# ("no such file" opening a shared library), and vice-versa.
307	# Work around it for now by using the strictly x86 compiler for x86, and x64 for x64.
308	# NOTE: What about ARM?
309	ifneq (,$(findstring x64,$(TargetArchMoniker)))
310		VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX64
311	else
312		VCCompilerToolsBinDir := $(VcCompilerToolsDir)\bin\HostX86
313	endif
314
315	PATH := $(shell IFS=$$'\n'; cygpath "$(VCCompilerToolsBinDir)/$(TargetArchMoniker)"):$(PATH)
316	PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VsInstallRoot)/Common7/IDE")
317	INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/include")
318	LIB := $(shell IFS=$$'\n'; cygpath -w "$(VcCompilerToolsDir)/lib/$(TargetArchMoniker)")
319	ifneq (,$(findstring uwp,$(PlatformSuffix)))
320		LIB := $(LIB);$(shell IFS=$$'\n'; cygpath -w "$(LIB)/store")
321	endif
322
323	export INCLUDE := $(INCLUDE);$(WindowsSDKSharedIncludeDir);$(WindowsSDKUCRTIncludeDir);$(WindowsSDKUMIncludeDir)
324	export LIB := $(LIB);$(WindowsSDKUCRTLibDir);$(WindowsSDKUMLibDir)
325	TARGET := $(TARGET_NAME)_libretro.dll
326	PSS_STYLE :=2
327	LDFLAGS += -DLL
328
329else
330	CC ?= gcc
331	TARGET_64BIT := $(BUILD_64BIT)
332   TARGET  := $(TARGET_NAME)_libretro.dll
333   DEFINES += -DHAVE_FSEEKO -DHAVE_INTTYPES_H
334   CXXFLAGS += -fno-permissive
335   LDFLAGS += -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=../link.T
336endif
337
338ifeq ($(DEBUG), 1)
339   DEFINES += -O0 -g
340else ifeq ($(platform), wiiu)
341   DEFINES += -Os
342else ifeq ($(platform),genode)
343   DEFINES += -O2
344else ifneq (,$(findstring msvc,$(platform)))
345   DEFINES += -O2
346else
347   DEFINES += -O3
348endif
349
350ifeq ($(TARGET_64BIT), 1)
351   DEFINES += -DSIZEOF_SIZE_T=8 -DSCUMM_64BITS
352else
353   DEFINES += -DSIZEOF_SIZE_T=4
354endif
355
356###SCUMM VM
357CORE_DIR = ../../../..
358srcdir   = $(CORE_DIR)
359VPATH    = $(CORE_DIR)
360
361# Define toolset
362ifdef TOOLSET
363    CC        = $(TOOLSET)gcc
364    CXX       = $(TOOLSET)g++
365    LD        = $(TOOLSET)g++
366    AR        = $(TOOLSET)ar cru
367    RANLIB    = $(TOOLSET)ranlib
368endif
369
370MKDIR         = mkdir -p
371RM            = rm -f
372RM_REC        = rm -rf
373
374ifeq ($(HAVE_MT32EMU),1)
375USE_MT32EMU = 1
376DEFINES += -DUSE_MT32EMU
377endif
378
379# Define build flags
380DEFINES       += -D__LIBRETRO__ -DNONSTANDARD_PORT -DUSE_RGB_COLOR -DUSE_OSD -DDISABLE_TEXT_CONSOLE -DFRONTEND_SUPPORTS_RGB565
381DEPDIR        = .deps
382HAVE_GCC3     = true
383USE_RGB_COLOR = true
384
385DEFINES += -Wno-multichar -Wno-unknown-pragmas -Wno-write-strings
386CXXFLAGS += -Wno-reorder
387
388# Compile platform specific parts (e.g. filesystem)
389ifeq ($(platform), win)
390WIN32 = 1
391endif
392
393BACKEND := libretro
394
395include Makefile.common
396
397######################################################################
398# The build rules follow - normally you should have no need to
399# touch whatever comes after here.
400######################################################################
401
402# Concat DEFINES and INCLUDES to form the CPPFLAGS
403CPPFLAGS := $(DEFINES) $(INCLUDES) $(INCFLAGS)
404CXXFLAGS += $(DEFINES) $(INCLUDES)
405CFLAGS += $(DEFINES) $(INCLUDES)
406
407# Include the build instructions for all modules
408-include $(addprefix $(CORE_DIR)/, $(addsuffix /module.mk,$(MODULES)))
409
410# Depdir information
411DEPDIRS = $(addsuffix $(DEPDIR),$(MODULE_DIRS))
412
413# Hack for libnx DEPSDIR issues
414libnx-ln:
415ifeq ($(platform), libnx)
416	ln -s ../../../../audio/ audio
417	ln -s ../../../../backends/ backends
418	ln -s ../../../../base/ base
419	ln -s ../../../../common/ common
420	ln -s ../../../../engines/ engines
421	ln -s ../../../../graphics/ graphics
422	ln -s ../../../../gui/ gui
423	ln -s ../../../../image/ image
424	ln -s ../../../../video/ video
425	touch libnx-ln
426endif
427
428OBJOUT   = -o
429LINKOUT  = -o
430
431ifneq (,$(findstring msvc,$(platform)))
432	OBJOUT = -Fo
433	LINKOUT = -out:
434ifeq ($(STATIC_LINKING),1)
435	LD ?= lib.exe
436	STATIC_LINKING=0
437else
438	LD = link.exe
439endif
440endif
441
442ifeq ($(platform), wiiu)
443$(TARGET): $(OBJS) libdeps.a
444	$(MKDIR) libtemp
445	$(CP) $+ libtemp/
446	$(AR_ALONE) -M < lite_wiiu.mri
447else ifeq ($(platform), libnx)
448$(TARGET): libnx-ln $(OBJS) libdeps.a
449	$(MKDIR) libtemp
450	cp $+ libtemp/
451	$(AR) -M < libnx.mri
452else ifeq ($(STATIC_LINKING), 1)
453$(TARGET): $(OBJS) libdeps.a
454	@echo Linking $@...
455	$(HIDE)$(AR) $@ $(wildcard *.o) $(wildcard */*.o) $(wildcard */*/*.o) $(wildcard */*/*/*.o) $(wildcard */*/*/*/*.o)  $(wildcard */*/*/*/*/*.o)
456else
457$(TARGET): $(OBJS) libdeps.a
458	@echo Linking $@...
459	$(HIDE)$(LD) $(LDFLAGS) $+ $(LIBS) $(LINKOUT)$@
460endif
461
462libdeps.a: $(OBJS_DEPS)
463ifeq ($(platform), libnx)
464		@echo Linking $@...
465		$(HIDE)$(AR) -rc $@ $^
466else
467		@echo Linking $@...
468		$(HIDE)$(AR) $@ $^
469endif
470
471%.o: %.c
472	@echo Compiling $(<F)...
473	@$(MKDIR) $(*D)
474	$(HIDE)$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
475
476%.o: %.cpp
477	@echo Compiling $(<F)...
478	@$(MKDIR) $(*D)
479	$(HIDE)$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
480
481# Dumb compile rule, for C++ compilers that don't allow dependency tracking or
482# where it is broken (such as GCC 2.95).
483.cpp.o:
484	@$(MKDIR) $(*D)
485	@echo Compiling $<...
486	$(HIDE)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $(<) $(OBJOUT)$*.o
487
488clean:
489	@echo Cleaning project...
490	$(HIDE)$(RM_REC) $(DEPDIRS)
491	$(HIDE)$(RM) $(OBJS) $(OBJS_DEPS) libdeps.a $(TARGET)
492ifeq ($(platform), wiiu)
493	$(HIDE)$(RM_REC) libtemp
494endif
495ifeq ($(platform), libnx)
496	$(HIDE)$(RM_REC) libtemp
497	$(HIDE)$(RM) audio
498	$(HIDE)$(RM) backends
499	$(HIDE)$(RM) base
500	$(HIDE)$(RM) common
501	$(HIDE)$(RM) engines
502	$(HIDE)$(RM) graphics
503	$(HIDE)$(RM) gui
504	$(HIDE)$(RM) image
505	$(HIDE)$(RM) video
506	$(HIDE)$(RM) libnx-ln
507endif
508
509# Include the dependency tracking files.
510-include $(wildcard $(addsuffix /*.d,$(DEPDIRS)))
511
512# Mark *.d files and most *.mk files as PHONY. This stops make from trying to
513# recreate them (which it can't), and in particular from looking for potential
514# source files. This can save quite a bit of disk access time.
515.PHONY: $(wildcard $(addsuffix /*.d,$(DEPDIRS))) $(addprefix $(CORE_DIR)/, $(addsuffix /module.mk,$(MODULES))) \
516	$(CORE_DIR)/$(port_mk) $(CORE_DIR)/rules.mk $(CORE_DIR)/engines/engines.mk
517
518.PHONY: all clean
519