-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
323 lines (276 loc) · 7.78 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
########################
#
# libvgm Makefile
#
########################
DEBUG = 0
ifeq ($(OS),Windows_NT)
WINDOWS = 1
else
WINDOWS = 0
endif
ifeq ($(WINDOWS), 0)
USE_BSD_AUDIO = 0
USE_ALSA = 1
USE_LIBAO = 1
USE_PULSE = 1
endif
CC = gcc
CXX = g++
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man
ifeq ($(DEBUG), 1)
CFLAGS := -O0 -g $(CFLAGS) -D_DEBUG -I.
else
CFLAGS := -O2 -g0 $(CFLAGS) -I.
endif
CCFLAGS = -std=gnu90
CXXFLAGS = -std=gnu++98
ARFLAGS = -cr
CFLAGS += -Wall
#CFLAGS += -Wextra
#CFLAGS += -Wpedantic
CFLAGS += -Wno-unused-parameter -Wno-unused-but-set-variable -Wno-long-long
# silence typical sound core warnings
ifneq ($(DEBUG), 1)
CFLAGS += -Wno-unknown-pragmas
CFLAGS += -Wno-unused-value -Wno-sign-compare
CFLAGS += -Wno-unused-variable -Wno-unused-const-variable -Wno-unused-function
endif
# additional warnings from http://blog.httrack.com/blog/2014/03/09/what-are-your-gcc-flags/
CFLAGS += -Wpointer-arith -Winit-self -Wstrict-aliasing
CFLAGS += -Wformat -Wformat-security -Wformat-nonliteral
#CFLAGS += -fstack-protector -Wpointer-arith -Winit-self
#LDFLAGS += -fstack-protector
# add Library Path, if defined
ifdef LD_LIBRARY_PATH
LDFLAGS += -L $(LD_LIBRARY_PATH)
endif
#CFLAGS += -D__BIG_ENDIAN__
ifeq ($(WINDOWS), 1)
CFLAGS += -Ilibs/include_mingw
# assume Windows 2000 and later for GetConsoleWindow API call
CFLAGS += -D _WIN32_WINNT=0x500
endif
ifeq ($(WINDOWS), 1)
# for Windows, add kernel32 and winmm (Multimedia APIs)
LDFLAGS += -lkernel32 -lwinmm -ldsound -luuid -lole32
else
# for Linux add pthread support (-pthread should include -lpthread)
LDFLAGS += -lrt -pthread
CFLAGS += -pthread -DSHARE_PREFIX=\"$(PREFIX)\"
# add librt (clock stuff)
#LDFLAGS += -lrt
endif
SRC = .
OBJ = obj
LIBAUDSRC = $(SRC)/audio
LIBAUDOBJ = $(OBJ)/audio
LIBEMUSRC = $(SRC)/emu
LIBEMUOBJ = $(OBJ)/emu
UTILSRC = $(SRC)/utils
UTILOBJ = $(OBJ)/utils
OBJDIRS = \
$(OBJ) \
$(LIBAUDOBJ) \
$(LIBEMUOBJ) \
$(LIBEMUOBJ)/cores \
$(OBJ)/vgm \
$(UTILOBJ) \
$(OBJ)/player
ALL_LIBS = \
$(LIBAUD_A) \
$(LIBEMU_A)
#### Audio Output Library ####
AUD_MAINOBJS = \
$(OBJ)/audiotest.o
LIBAUD_A = $(OBJ)/libaudio.a
LIBAUDOBJS = \
$(LIBAUDOBJ)/AudioStream.o \
$(LIBAUDOBJ)/AudDrv_WaveWriter.o
CFLAGS += -D AUDDRV_WAVEWRITE
ifeq ($(WINDOWS), 1)
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_WinMM.o \
$(LIBAUDOBJ)/AudDrv_DSound.o \
$(LIBAUDOBJ)/AudDrv_XAudio2.o
#$(LIBAUDOBJ)/AudDrv_WASAPI.o # MinGW lacks the required header files
CFLAGS += -D AUDDRV_WINMM
CFLAGS += -D AUDDRV_DSOUND
CFLAGS += -D AUDDRV_XAUD2
#CFLAGS += -D AUDDRV_WASAPI
endif
ifneq ($(WINDOWS), 1)
ifneq ($(USE_BSD_AUDIO), 1)
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_OSS.o
CFLAGS += -D AUDDRV_OSS
else
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_SADA.o
CFLAGS += -D AUDDRV_SADA
endif
ifeq ($(USE_ALSA), 1)
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_ALSA.o
LDFLAGS += -lasound
CFLAGS += -D AUDDRV_ALSA
endif
ifeq ($(USE_PULSE), 1)
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_Pulse.o
LDFLAGS += -lpulse-simple -lpulse
CFLAGS += -D AUDDRV_PULSE
endif
endif
ifeq ($(USE_LIBAO), 1)
LIBAUDOBJS += \
$(LIBAUDOBJ)/AudDrv_libao.o
LDFLAGS += -lao
CFLAGS += -D AUDDRV_LIBAO
endif
#### Sound Emulation Library ####
EMU_MAINOBJS = \
$(OBJ)/emutest.o
LIBEMU_A = $(OBJ)/libemu.a
LIBEMUOBJS = \
$(LIBEMUOBJ)/SoundEmu.o \
$(LIBEMUOBJ)/cores/sn764intf.o \
$(LIBEMUOBJ)/cores/sn76496.o \
$(LIBEMUOBJ)/cores/sn76489.o \
$(LIBEMUOBJ)/cores/2413intf.o \
$(LIBEMUOBJ)/cores/emu2413.o \
$(LIBEMUOBJ)/cores/ym2413.o \
$(LIBEMUOBJ)/cores/nukedopll.o \
$(LIBEMUOBJ)/cores/2612intf.o \
$(LIBEMUOBJ)/cores/fmopn2612.o \
$(LIBEMUOBJ)/cores/ym2612.o \
$(LIBEMUOBJ)/cores/ym3438.o \
$(LIBEMUOBJ)/cores/ym2151.o \
$(LIBEMUOBJ)/cores/segapcm.o \
$(LIBEMUOBJ)/cores/rf5cintf.o \
$(LIBEMUOBJ)/cores/rf5c68.o \
$(LIBEMUOBJ)/cores/scd_pcm.o \
$(LIBEMUOBJ)/cores/opnintf.o \
$(LIBEMUOBJ)/cores/fmopn.o \
$(LIBEMUOBJ)/cores/ymdeltat.o \
$(LIBEMUOBJ)/cores/oplintf.o \
$(LIBEMUOBJ)/cores/fmopl.o \
$(LIBEMUOBJ)/cores/adlibemu_opl2.o \
$(LIBEMUOBJ)/cores/262intf.o \
$(LIBEMUOBJ)/cores/ymf262.o \
$(LIBEMUOBJ)/cores/adlibemu_opl3.o \
$(LIBEMUOBJ)/cores/nukedopl3.o \
$(LIBEMUOBJ)/cores/ymf278b.o \
$(LIBEMUOBJ)/cores/ymf271.o \
$(LIBEMUOBJ)/cores/ymz280b.o \
$(LIBEMUOBJ)/cores/ayintf.o \
$(LIBEMUOBJ)/cores/ay8910.o \
$(LIBEMUOBJ)/cores/emu2149.o \
$(LIBEMUOBJ)/cores/pwm.o \
$(LIBEMUOBJ)/cores/gb.o \
$(LIBEMUOBJ)/cores/nesintf.o \
$(LIBEMUOBJ)/cores/nes_apu.o \
$(LIBEMUOBJ)/cores/np_nes_apu.o \
$(LIBEMUOBJ)/cores/np_nes_dmc.o \
$(LIBEMUOBJ)/cores/np_nes_fds.o \
$(LIBEMUOBJ)/cores/multipcm.o \
$(LIBEMUOBJ)/cores/upd7759.o \
$(LIBEMUOBJ)/cores/okim6258.o \
$(LIBEMUOBJ)/cores/okim6295.o \
$(LIBEMUOBJ)/cores/okiadpcm.o \
$(LIBEMUOBJ)/cores/k051649.o \
$(LIBEMUOBJ)/cores/k054539.o \
$(LIBEMUOBJ)/cores/c6280intf.o \
$(LIBEMUOBJ)/cores/c6280_mame.o \
$(LIBEMUOBJ)/cores/Ootake_PSG.o \
$(LIBEMUOBJ)/cores/c140.o \
$(LIBEMUOBJ)/cores/c219.o \
$(LIBEMUOBJ)/cores/k053260.o \
$(LIBEMUOBJ)/cores/pokey.o \
$(LIBEMUOBJ)/cores/qsoundintf.o \
$(LIBEMUOBJ)/cores/qsound_mame.o \
$(LIBEMUOBJ)/cores/qsound_ctr.o \
$(LIBEMUOBJ)/cores/scsp.o \
$(LIBEMUOBJ)/cores/scspdsp.o \
$(LIBEMUOBJ)/cores/ws_audio.o \
$(LIBEMUOBJ)/cores/vsu.o \
$(LIBEMUOBJ)/cores/saaintf.o \
$(LIBEMUOBJ)/cores/saa1099_mame.o \
$(LIBEMUOBJ)/cores/saa1099_vb.o \
$(LIBEMUOBJ)/cores/es5503.o \
$(LIBEMUOBJ)/cores/es5506.o \
$(LIBEMUOBJ)/cores/x1_010.o \
$(LIBEMUOBJ)/cores/c352.o \
$(LIBEMUOBJ)/cores/iremga20.o \
$(LIBEMUOBJ)/Resampler.o \
$(LIBEMUOBJ)/panning.o \
$(LIBEMUOBJ)/dac_control.o
UTILOBJS = \
$(UTILOBJ)/OSMutex_POSIX.o \
$(UTILOBJ)/OSSignal_POSIX.o \
$(UTILOBJ)/OSThread_POSIX.o
AUDEMU_MAINOBJS = \
$(OBJ)/audemutest.o
VGMTEST_MAINOBJS = \
$(OBJ)/player/dblk_compr.o \
$(OBJ)/vgmtest.o
PLAYER_MAINOBJS = \
$(OBJ)/player/helper.o \
$(UTILOBJ)/DataLoader.o \
$(UTILOBJ)/FileLoader.o \
$(UTILOBJ)/MemoryLoader.o \
$(UTILOBJ)/StrUtils-CPConv_IConv.o \
$(OBJ)/player/playerbase.o \
$(OBJ)/player/s98player.o \
$(OBJ)/player/droplayer.o \
$(OBJ)/player/vgmplayer.o \
$(OBJ)/player/vgmplayer_cmdhandler.o \
$(OBJ)/player/dblk_compr.o \
$(OBJ)/player.o
all: audiotest emutest audemutest vgmtest plrtest
audiotest: dirs libaudio $(UTILOBJS) $(AUD_MAINOBJS)
@echo Linking audiotest ...
@$(CC) $(UTILOBJS) $(AUD_MAINOBJS) $(LIBAUD_A) $(LDFLAGS) -o $@
@echo Done.
libaudio: $(LIBAUDOBJS)
@echo Archiving libaudio.a ...
@$(AR) $(ARFLAGS) $(LIBAUD_A) $(LIBAUDOBJS)
emutest: dirs libemu $(EMU_MAINOBJS)
@echo Linking emutest ...
@$(CC) $(EMU_MAINOBJS) $(LIBEMU_A) $(LDFLAGS) -lm -o $@
@echo Done.
libemu: $(LIBEMUOBJS)
@echo Archiving libemu.a ...
@$(AR) $(ARFLAGS) $(LIBEMU_A) $(LIBEMUOBJS)
audemutest: dirs libaudio libemu $(UTILOBJS) $(AUDEMU_MAINOBJS)
@echo Linking audemutest ...
@$(CC) $(UTILOBJS) $(AUDEMU_MAINOBJS) $(LIBAUD_A) $(LIBEMU_A) $(LDFLAGS) -lm -o $@
@echo Done.
vgmtest: dirs libaudio libemu $(UTILOBJS) $(VGMTEST_MAINOBJS)
@echo Linking vgmtest ...
@$(CC) $(UTILOBJS) $(VGMTEST_MAINOBJS) $(LIBAUD_A) $(LIBEMU_A) $(LDFLAGS) -lz -lm -o $@
@echo Done.
plrtest: dirs libaudio libemu $(UTILOBJS) $(PLAYER_MAINOBJS)
@echo Linking $@ ...
@$(CXX) $(UTILOBJS) $(PLAYER_MAINOBJS) $(LIBAUD_A) $(LIBEMU_A) $(LDFLAGS) -lz -lm -o $@
@echo Done.
vgm_dbcompr_bench: vgm_dbcompr_bench.c vgm/dblk_compr.c
@echo Compiling+Linking vgm_dbcompr_bench
@$(CC) $(CFLAGS) $(CCFLAGS) $^ $(LDFLAGS) -o vgm_dbcompr_bench
@echo Done.
dirs:
@mkdir -p $(OBJDIRS)
$(OBJ)/%.o: $(SRC)/%.c
@echo Compiling $< ...
@$(CC) $(CFLAGS) $(CCFLAGS) -c $< -o $@
$(OBJ)/%.o: $(SRC)/%.cpp
@echo Compiling $< ...
@$(CXX) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
clean:
@echo Deleting object files ...
@rm -f $(AUD_MAINOBJS) $(EMU_MAINOBJS) $(AUDEMU_MAINOBJS) $(VGMTEST_MAINOBJS) $(S98TEST_MAINOBJS) $(ALL_LIBS) $(LIBAUDOBJS) $(LIBEMUOBJS)
@echo Deleting executable files ...
@rm -f audiotest emutest audemutest vgmtest
@echo Done.
#.PHONY: all clean install uninstall