-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile-gme
102 lines (87 loc) · 2.6 KB
/
Makefile-gme
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
# build architecture inspired by this page:
# http://make.mad-scientist.net/papers/multi-architecture-builds/
ifeq ($(notdir $(CURDIR)), cirrusretro-players)
include target-gme.mk
else
TARGET:=cr-gme-$(GME_PLAYER).js
CC:=ccache emcc
CXX:=ccache em++
LD:=em++
GME_SRCDIR=$(SRCDIR)/gme-source-0.6.0
XZ_EMBEDDED_SRCDIR=$(SRCDIR)/xz-embedded
VPATH=$(SRCDIR):$(GME_SRCDIR):$(XZ_EMBEDDED_SRCDIR)
FINALDIR=$(SRCDIR)/final
EXPORT_LIST="['_crPlayerContextSize', '_crPlayerInitialize', '_crPlayerLoadFile', '_crPlayerSetTrack', '_crPlayerGenerateStereoFrames', '_crPlayerVoicesCanBeToggled', '_crPlayerGetVoiceCount', '_crPlayerGetVoiceName', '_crPlayerSetVoiceState', '_crPlayerCleanup', '_main']"
# the amount of memory that the Emscripten process gets to use
MEGABYTES=48
TOTAL_MEMORY=$(shell echo $(MEGABYTES)\*1024\*1024 | bc)
# GME source files, plus the Cirrus Retro glue file
GME_CXX_SOURCES:=gme_interface.cpp \
Ay_Apu.cpp \
Ay_Cpu.cpp \
Ay_Emu.cpp \
Blip_Buffer.cpp \
Classic_Emu.cpp \
Data_Reader.cpp \
Dual_Resampler.cpp \
Effects_Buffer.cpp \
Fir_Resampler.cpp \
Gb_Apu.cpp \
Gb_Cpu.cpp \
Gb_Oscs.cpp \
Gbs_Emu.cpp \
gme.cpp \
Gme_File.cpp \
Gym_Emu.cpp \
Hes_Apu.cpp \
Hes_Cpu.cpp \
Hes_Emu.cpp \
Kss_Cpu.cpp \
Kss_Emu.cpp \
Kss_Scc_Apu.cpp \
M3u_Playlist.cpp \
Multi_Buffer.cpp \
Music_Emu.cpp \
Nes_Apu.cpp \
Nes_Cpu.cpp \
Nes_Fme7_Apu.cpp \
Nes_Namco_Apu.cpp \
Nes_Oscs.cpp \
Nes_Vrc6_Apu.cpp \
Nsfe_Emu.cpp \
Nsf_Emu.cpp \
Sap_Apu.cpp \
Sap_Cpu.cpp \
Sap_Emu.cpp \
Sms_Apu.cpp \
Snes_Spc.cpp \
Spc_Cpu.cpp \
Spc_Dsp.cpp \
Spc_Emu.cpp \
Spc_Filter.cpp \
Vgm_Emu.cpp \
Vgm_Emu_Impl.cpp \
Ym2413_Emu.cpp \
Ym2612_Emu.cpp
#XZ-embedded sources
XZ_EMBEDDED_C_SOURCES:=xzdec.c \
xz_crc32.c \
xz_dec_lzma2.c \
xz_dec_stream.c
# Emscripten gets nervous when C/C++ compile flags reference absolute paths;
# '-Wno-warn-absolute-paths' tells the compiler not to worry
GME_CXXFLAGS:=-Wall -Wno-warn-absolute-paths -Os -I$(GME_SRCDIR) -DHAVE_CONFIG_H -I$(GME_SRCDIR)/config-headers/$(GME_PLAYER)
GME_CXX_OBJECTS:=$(patsubst %.cpp,%.o,$(GME_CXX_SOURCES))
# build rule for GME C++ files
%.o : %.cpp
$(CXX) -o $@ -c $< $(GME_CXXFLAGS)
XZ_EMBEDDED_C_FLAGS:= -Wall -Wno-warn-absolute-paths -Os -I$(XZ_EMBEDDED_SRCDIR)
XZ_EMBEDDED_C_OBJECTS:=$(patsubst %.c,%.o,$(XZ_EMBEDDED_C_SOURCES))
# build rule for XZ-embedded C files
%.o : %.c
$(CC) -o $@ -c $< $(XZ_EMBEDDED_C_FLAGS)
$(TARGET): $(GME_CXX_OBJECTS) $(XZ_EMBEDDED_C_OBJECTS)
$(LD) -o $(TARGET) $^ --memory-init-file 0 -Wall -Os -s EXPORTED_FUNCTIONS=$(EXPORT_LIST) -s TOTAL_MEMORY=$(TOTAL_MEMORY)
mkdir -p $(FINALDIR)
cp $(TARGET)* $(FINALDIR)
endif