forked from vgmstream/vgmstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
300 lines (248 loc) · 7.63 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
###############################
# vgmstream makefile
###############################
ifeq ($(VGMSTREAM_VERSION),)
# for current dir (expanded later)
VGMSTREAM_VERSION=`sh ./version-get.sh`
else
VGMSTREAM_VERSION=$(VGMSTREAM_VERSION)
endif
DEF_CFLAGS += -DVGMSTREAM_VERSION_AUTO -DVGM_LOG_OUTPUT
VGM_X64=0
###############################################################################
### external defs
# currently aimed to WIN32 builds but vgmstream-cli should work for others (or use autotools instead)
export TARGET_OS = $(OS)
#for Win builds with vgmstream123
LIBAO_DLL_PATH = ../libao/bin
### tools
RMF = rm -f
ifeq ($(TARGET_OS),Windows_NT)
SHELL = sh
CC = gcc
AR = ar
STRIP = strip
WINDRES = windres
DLLTOOL = dlltool
DLL_DIR = .
export DLL_DIR
ifneq ($(VGM_X64),0)
DLLTOOL = dlltool -m i386:x86-64 --as-flags --64
DLL_DIR = dll-x64
endif
# same thing, the above should be available
#CC = i686-w64-mingw32-gcc
#AR = i686-w64-mingw32-ar
#STRIP = i686-w64-mingw32-strip
#WINDRES = i686-w64-mingw32-windres
#DLLTOOL = i686-w64-mingw32-dlltool
else
SHELL = /bin/sh
CC = gcc
AR = ar
STRIP = strip
WINDRES =
DLLTOOL =
# (old crosscompile, not used anymore?)
#CC = i586-mingw32msvc-gcc
#AR = i586-mingw32msvc-ar
#STRIP = i586-mingw32msvc-strip
#WINDRES = i586-mingw32msvc-windres
#DLLTOOL = i586-mingw32msvc-dlltool
endif
export RMF SHELL CC AR STRIP WINDRES DLLTOOL
###############################################################################
### build defs
DEF_CFLAGS += -ffast-math -O3 -Wall -Werror=format-security -Wvla -Wimplicit-function-declaration -Wignored-qualifiers
VGM_DEBUG_FLAGS = 0
ifeq ($(VGM_DEBUG_FLAGS),1)
#DEF_CFLAGS += -O0
DEF_CFLAGS += -g -DVGM_DEBUG_OUTPUT
DEF_CFLAGS += -Wall
DEF_CFLAGS += -Wextra
DEF_CFLAGS += -Wno-sign-compare
DEF_CFLAGS += -Wlogical-op
#DEF_CFLAGS += -pedantic -Wconversion -std=gnu90
#DEF_CFLAGS += -Wfloat-equal
DEF_CFLAGS += -Wdisabled-optimization -Wunsafe-loop-optimizations -Wswitch-default
DEF_CFLAGS += -Wcast-qual -Wpointer-arith
DEF_CFLAGS += -Wcast-align=strict -Wduplicated-cond -Wjump-misses-init -Wnull-dereference
DEF_CFLAGS += -Wold-style-definition -Wstrict-prototypes
DEF_CFLAGS += -Wmultistatement-macros -Wstringop-truncation
DEF_CFLAGS += -Wredundant-decls -Wmissing-include-dirs -Wmissing-declarations
#DEF_CFLAGS += -Wshadow
#DEF_CFLAGS += -Wstack-protector -fstack-protector
STRIP = echo
endif
LIBS_CFLAGS=
LIBS_LDFLAGS=
LIBS_TARGET_EXT_LIBS=
### bit stuff
# TODO: some targets don't work with X64 (Winamp, etc), detect
#ifneq ($(VGM_X86),0)
# DEF_CFLAGS += -m32
#endif
ifneq ($(VGM_X64),0)
DEF_CFLAGS += -m64
endif
# config libs
VGM_G7221 = 1
ifneq ($(VGM_G7221),0)
LIBS_CFLAGS += -DVGM_USE_G7221
endif
### external libs
# (call "make VGM_xxx = 0/1" to override 0/1 defaults, as Make does)
ifeq ($(TARGET_OS),Windows_NT)
# enabled by default on Windows
VGM_VORBIS = 1
ifneq ($(VGM_VORBIS),0)
LIBS_CFLAGS += -DVGM_USE_VORBIS
LIBS_LDFLAGS += -lvorbis
LIBS_TARGET_EXT_LIBS += libvorbis.dll.a
endif
VGM_MPEG = 1
ifneq ($(VGM_MPEG),0)
LIBS_CFLAGS += -DVGM_USE_MPEG
LIBS_LDFLAGS += -lmpg123-0
LIBS_TARGET_EXT_LIBS += libmpg123-0.dll.a
endif
VGM_G719 = 1
ifneq ($(VGM_G719),0)
LIBS_CFLAGS += -DVGM_USE_G719
LIBS_LDFLAGS += -lg719_decode
LIBS_TARGET_EXT_LIBS += libg719_decode.dll.a
endif
VGM_FFMPEG = 1
ifneq ($(VGM_FFMPEG),0)
LIBS_CFLAGS += -DVGM_USE_FFMPEG -I../ext_includes/ffmpeg
LIBS_LDFLAGS += -lavcodec-vgmstream-59 -lavformat-vgmstream-59 -lavutil-vgmstream-57 -lswresample-vgmstream-4
LIBS_TARGET_EXT_LIBS += avcodec-vgmstream-59.dll.a avformat-vgmstream-59.dll.a avutil-vgmstream-57.dll.a swresample-vgmstream-4.dll.a
endif
VGM_ATRAC9 = 1
ifneq ($(VGM_ATRAC9),0)
LIBS_CFLAGS += -DVGM_USE_ATRAC9
LIBS_LDFLAGS += -latrac9
LIBS_TARGET_EXT_LIBS += libatrac9.dll.a
endif
VGM_CELT = 1
ifneq ($(VGM_CELT),0)
LIBS_CFLAGS += -DVGM_USE_CELT
LIBS_LDFLAGS += -lcelt-0061 -lcelt-0110
LIBS_TARGET_EXT_LIBS += libcelt-0061.dll.a libcelt-0110.dll.a
endif
VGM_SPEEX = 1
ifneq ($(VGM_SPEEX),0)
LIBS_CFLAGS += -DVGM_USE_SPEEX
LIBS_LDFLAGS += -lspeex-1
LIBS_TARGET_EXT_LIBS += libspeex-1.dll.a
endif
else
# must install system libs and enable manually on Linux
VGM_VORBIS = 0
ifneq ($(VGM_VORBIS),0)
LIBS_CFLAGS += -DVGM_USE_VORBIS
LIBS_LDFLAGS += -lvorbis -lvorbisfile
endif
VGM_MPEG = 0
ifneq ($(VGM_MPEG),0)
LIBS_CFLAGS += -DVGM_USE_MPEG
LIBS_LDFLAGS += -lmpg123
endif
VGM_G719 = 0
ifneq ($(VGM_G719),0)
LIBS_CFLAGS += -DVGM_USE_G719
LIBS_LDFLAGS += -lg719_decode
endif
VGM_FFMPEG = 0
ifneq ($(VGM_FFMPEG),0)
LIBS_CFLAGS += -DVGM_USE_FFMPEG
LIBS_LDFLAGS += -lavcodec -lavformat -lavutil -lswresample
endif
VGM_ATRAC9 = 0
ifneq ($(VGM_ATRAC9),0)
LIBS_CFLAGS += -DVGM_USE_ATRAC9
ifeq ($(VGM_ATRAC9),1)
LIBS_LDFLAGS += -latrac9
endif
ifeq ($(VGM_ATRAC9),2)
LIBS_LDFLAGS += -l:libatrac9.a
endif
endif
VGM_CELT = 0
ifneq ($(VGM_CELT),0)
LIBS_CFLAGS += -DVGM_USE_CELT
ifeq ($(VGM_CELT),1)
LIBS_LDFLAGS += -lcelt-0061 -lcelt-0110
endif
ifeq ($(VGM_CELT),2)
LIBS_LDFLAGS += -l:libcelt-0061.a -l:libcelt-0110.a
endif
endif
VGM_SPEEX = 0
ifneq ($(VGM_SPEEX),0)
LIBS_CFLAGS += -DVGM_USE_SPEEX
LIBS_LDFLAGS += -lspeex
endif
endif
export DEF_CFLAGS LIBS_CFLAGS LIBS_LDFLAGS LIBS_TARGET_EXT_LIBS
###############################################################################
### internal defs
ifeq ($(TARGET_OS),Windows_NT)
BIN_FILE = vgmstream-$(VGMSTREAM_VERSION)-win.zip
ZIP_FILES = COPYING
ZIP_FILES += README.md
ZIP_FILES += doc/USAGE.md
ZIP_FILES += cli/vgmstream-cli.exe
ZIP_FILES += winamp/in_vgmstream.dll
ZIP_FILES += xmplay/xmp-vgmstream.dll
ZIP_FILES += ext_libs/*.dll
ZIP_FILES_AO = cli/vgmstream123.exe
ZIP_FILES_AO += $(LIBAO_DLL_PATH)/*.dll
else
BIN_FILE = vgmstream-$(VGMSTREAM_VERSION)-bin.zip
ZIP_FILES = COPYING
ZIP_FILES += README.md
ZIP_FILES += doc/USAGE.md
ZIP_FILES += cli/vgmstream-cli
ZIP_FILES_AO = cli/vgmstream123
endif
###############################################################################
### targets
buildrelease: clean bin
buildrelease-ex: clean bin-ex
buildfullrelease: clean sourceball bin
# make a tmp copy of git's index to avoid including dev stuff
sourceball:
rm -rf vgmstream-$(VGMSTREAM_VERSION)
git checkout-index -f -a --prefix=vgmstream-$(VGMSTREAM_VERSION)/
# echo "#!/bin/sh" > vgmstream-$(VGMSTREAM_VERSION)/version-get.sh
# echo "echo \"$(VGMSTREAM_VERSION)\"" >> vgmstream-$(VGMSTREAM_VERSION)/version-get.sh
tar cvzf "bin/vgmstream-$(VGMSTREAM_VERSION)-src.tar.gz" vgmstream-$(VGMSTREAM_VERSION)/*
# git archive --format zip --output bin/vgmstream-$(VGMSTREAM_VERSION)-src.zip master
rm -rf vgmstream-$(VGMSTREAM_VERSION)
bin: vgmstream-cli winamp xmplay
mkdir -p bin
zip -FS -j "bin/$(BIN_FILE)" $(ZIP_FILES)
#separate since vgmstream123 is kinda untested
bin-ex: vgmstream-cli winamp xmplay vgmstream123
mkdir -p bin
zip -FS -j "bin/$(BIN_FILE)" $(ZIP_FILES) $(ZIP_FILES_AO)
vgmstream-cli: vgmstream_cli
vgmstream_cli: version
$(MAKE) -C cli vgmstream_cli
vgmstream123: version
$(MAKE) -C cli vgmstream123
winamp: version
$(MAKE) -C winamp in_vgmstream
xmplay: version
$(MAKE) -C xmplay xmp_vgmstream
version:
sh version-make.sh
clean:
$(RMF) vgmstream-*.zip
$(MAKE) -C src clean
$(MAKE) -C cli clean
$(MAKE) -C winamp clean
$(MAKE) -C xmplay clean
$(MAKE) -C ext_libs clean
.PHONY: clean buildfullrelease buildrelease sourceball bin vgmstream-cli vgmstream_cli vgmstream123 winamp xmplay version