4
|
1 #-----------------------------------------------------------------------------#
|
|
2 # SDL_sound -- An abstract sound format decoding API.
|
|
3 # Copyright (C) 2001 Ryan C. Gordon.
|
|
4 #
|
|
5 # This library is free software; you can redistribute it and/or
|
|
6 # modify it under the terms of the GNU Lesser General Public
|
|
7 # License as published by the Free Software Foundation; either
|
|
8 # version 2.1 of the License, or (at your option) any later version.
|
|
9 #
|
|
10 # This library is distributed in the hope that it will be useful,
|
|
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 # Lesser General Public License for more details.
|
|
14 #
|
|
15 # You should have received a copy of the GNU Lesser General Public
|
|
16 # License along with this library; if not, write to the Free Software
|
|
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 #
|
|
19 # (Please see the file LICENSE in the source's root directory.)
|
|
20 #
|
|
21 # This file written by Ryan C. Gordon.
|
|
22 #-----------------------------------------------------------------------------#
|
|
23
|
|
24
|
|
25 #-----------------------------------------------------------------------------#
|
|
26 # Makefile for building SDL_sound on Unix-like systems. Follow the
|
|
27 # instructions for editing this file, then run "make" on the command line.
|
|
28 #-----------------------------------------------------------------------------#
|
|
29
|
|
30
|
|
31 #-----------------------------------------------------------------------------#
|
|
32 # Set to your liking.
|
|
33 #-----------------------------------------------------------------------------#
|
|
34 CC = gcc
|
|
35 LINKER = gcc
|
|
36
|
|
37
|
|
38 #-----------------------------------------------------------------------------#
|
|
39 # If this makefile fails to detect Cygwin correctly, or you want to force
|
|
40 # the build process's behaviour, set it to "true" or "false" (w/o quotes).
|
|
41 #-----------------------------------------------------------------------------#
|
|
42 #cygwin := true
|
|
43 #cygwin := false
|
|
44 cygwin := autodetect
|
|
45
|
|
46 #-----------------------------------------------------------------------------#
|
|
47 # You only need to set SDL_INC_DIR and SDL_LIB_DIR if you are using cygwin.
|
|
48 # SDL_INC_DIR is where SDL.h and associated headers can be found, and
|
|
49 # SDL_LIB_DIR is where SDL.lib and SDL.dll are located. These may be set as
|
|
50 # environment variables, if you'd prefer to not hack the Makefile.
|
|
51 #
|
|
52 # examples:
|
|
53 # SDL_INC_DIR := C:/2/SDL-1.1.8/include
|
|
54 # SDL_LIB_DIR := C:/2/SDL-1.1.8/lib
|
|
55 #-----------------------------------------------------------------------------#
|
|
56 ifeq ($(strip $(SDL_INC_DIR)),)
|
|
57 SDL_INC_DIR := please_set_me_cygwin_users
|
|
58 endif
|
|
59
|
|
60 ifeq ($(strip $(SDL_LIB_DIR)),)
|
|
61 SDL_LIB_DIR := please_set_me_cygwin_users
|
|
62 endif
|
|
63
|
|
64 #-----------------------------------------------------------------------------#
|
|
65 # Set this to true if you want to create a debug build.
|
|
66 #-----------------------------------------------------------------------------#
|
|
67 #debugging := false
|
|
68 debugging := true
|
|
69
|
|
70 #-----------------------------------------------------------------------------#
|
|
71 # Set the decoder types you'd like to support.
|
|
72 # Note that various decoders may need external libraries.
|
|
73 #-----------------------------------------------------------------------------#
|
|
74 use_decoder_raw := true
|
|
75 use_decoder_voc := false
|
|
76
|
|
77 #-----------------------------------------------------------------------------#
|
|
78 # Set to "true" if you'd like to build a DLL. Set to "false" otherwise.
|
|
79 #-----------------------------------------------------------------------------#
|
|
80 #build_dll := false
|
|
81 build_dll := true
|
|
82
|
|
83 #-----------------------------------------------------------------------------#
|
|
84 # Set one of the below. Currently, none of these are used.
|
|
85 #-----------------------------------------------------------------------------#
|
|
86 #use_asm = -DUSE_I386_ASM
|
|
87 use_asm = -DUSE_PORTABLE_C
|
|
88
|
|
89
|
|
90 #-----------------------------------------------------------------------------#
|
|
91 # Set this to where you want SDL_sound installed. It will put the
|
|
92 # files in $(install_prefix)/bin, $(install_prefix)/lib, and
|
|
93 # $(install_prefix)/include ...
|
|
94 #-----------------------------------------------------------------------------#
|
|
95 install_prefix := /usr/local
|
|
96
|
|
97
|
|
98 #-----------------------------------------------------------------------------#
|
|
99 #-----------------------------------------------------------------------------#
|
|
100 #-----------------------------------------------------------------------------#
|
|
101 #-----------------------------------------------------------------------------#
|
|
102 # Everything below this line is probably okay.
|
|
103 #-----------------------------------------------------------------------------#
|
|
104 #-----------------------------------------------------------------------------#
|
|
105 #-----------------------------------------------------------------------------#
|
|
106 #-----------------------------------------------------------------------------#
|
|
107
|
|
108 #-----------------------------------------------------------------------------#
|
|
109 # CygWin autodetect.
|
|
110 #-----------------------------------------------------------------------------#
|
|
111
|
|
112 ifeq ($(strip $(cygwin)),autodetect)
|
|
113 ifneq ($(strip $(shell gcc -v 2>&1 |grep "cygwin")),)
|
|
114 cygwin := true
|
|
115 else
|
|
116 cygwin := false
|
|
117 endif
|
|
118 endif
|
|
119
|
|
120
|
|
121 #-----------------------------------------------------------------------------#
|
|
122 # Platform-specific binary stuff.
|
|
123 #-----------------------------------------------------------------------------#
|
|
124
|
|
125 ifeq ($(strip $(cygwin)),true)
|
|
126 ifeq ($(strip $(SDL_INC_DIR)),please_set_me_cygwin_users)
|
|
127 $(error Cygwin users need to set the SDL_INC_DIR envr var.)
|
|
128 else
|
|
129 SDL_CFLAGS := -I$(SDL_INC_DIR)
|
|
130 endif
|
|
131
|
|
132 ifeq ($(strip $(SDL_LIB_DIR)),please_set_me_cygwin_users)
|
|
133 $(error Cygwin users need to set the SDL_LIB_DIR envr var.)
|
|
134 else
|
|
135 SDL_LDFLAGS := -L$(SDL_LIB_DIR) -lSDL
|
|
136 endif
|
|
137
|
|
138 # !!! FIXME
|
|
139 build_dll := false
|
|
140 # !!! FIXME
|
|
141
|
|
142 ASM = nasmw
|
|
143 EXE_EXT = .exe
|
|
144 DLL_EXT = .dll
|
|
145 STATICLIB_EXT = .a
|
|
146 ASMOBJFMT = win32
|
|
147 ASMDEFS = -dC_IDENTIFIERS_UNDERSCORED
|
|
148 CFLAGS += -DC_IDENTIFIERS_UNDERSCORED
|
|
149 else
|
|
150 ASM = nasm
|
|
151 EXE_EXT =
|
|
152 DLL_EXT = .so
|
|
153 STATICLIB_EXT = .a
|
|
154 ASMOBJFMT = elf
|
|
155 SDL_CFLAGS := $(shell sdl-config --cflags)
|
|
156 SDL_LDFLAGS := $(shell sdl-config --libs)
|
|
157 endif
|
|
158
|
|
159 CFLAGS += $(SDL_CFLAGS)
|
|
160 LDFLAGS += $(SDL_LDFLAGS)
|
|
161
|
|
162 ifeq ($(strip $(build_dll)),true)
|
|
163 LIB_EXT := $(DLL_EXT)
|
|
164 SHAREDFLAGS += -shared
|
|
165 else
|
|
166 LIB_EXT := $(STATICLIB_EXT)
|
|
167 endif
|
|
168
|
|
169 #-----------------------------------------------------------------------------#
|
|
170 # Version crapola.
|
|
171 #-----------------------------------------------------------------------------#
|
|
172 VERMAJOR := $(shell grep "define SOUND_VER_MAJOR" SDL_sound.h | sed "s/\#define SOUND_VER_MAJOR //")
|
|
173 VERMINOR := $(shell grep "define SOUND_VER_MINOR" SDL_sound.h | sed "s/\#define SOUND_VER_MINOR //")
|
|
174 VERPATCH := $(shell grep "define SOUND_VER_PATCH" SDL_sound.h | sed "s/\#define SOUND_VER_PATCH //")
|
|
175
|
|
176 VERMAJOR := $(strip $(VERMAJOR))
|
|
177 VERMINOR := $(strip $(VERMINOR))
|
|
178 VERPATCH := $(strip $(VERPATCH))
|
|
179
|
|
180 VERFULL := $(VERMAJOR).$(VERMINOR).$(VERPATCH)
|
|
181
|
|
182 #-----------------------------------------------------------------------------#
|
|
183 # General compiler, assembler, and linker flags.
|
|
184 #-----------------------------------------------------------------------------#
|
|
185
|
|
186 BINDIR := bin
|
|
187 SRCDIR := .
|
|
188
|
|
189 CFLAGS += $(use_asm) -I$(SRCDIR) -D_REENTRANT -fsigned-char -DPLATFORM_UNIX
|
|
190 CFLAGS += -Wall -Werror -fno-exceptions -fno-rtti -ansi -pedantic
|
|
191
|
|
192 LDFLAGS += -lm
|
|
193
|
|
194 ifeq ($(strip $(debugging)),true)
|
|
195 CFLAGS += -DDEBUG -g -fno-omit-frame-pointer
|
|
196 LDFLAGS += -g -fno-omit-frame-pointer
|
|
197 else
|
|
198 CFLAGS += -DNDEBUG -O2 -fomit-frame-pointer
|
|
199 LDFLAGS += -O2 -fomit-frame-pointer
|
|
200 endif
|
|
201
|
|
202 ASMFLAGS := -f $(ASMOBJFMT) $(ASMDEFS)
|
|
203
|
|
204 #-----------------------------------------------------------------------------#
|
|
205 # Source and target names.
|
|
206 #-----------------------------------------------------------------------------#
|
|
207
|
|
208 PUREBASELIBNAME := SDL_sound
|
|
209 ifeq ($(strip $(cygwin)),true)
|
|
210 BASELIBNAME := $(strip $(PUREBASELIBNAME))
|
|
211 else
|
|
212 BASELIBNAME := lib$(strip $(PUREBASELIBNAME))
|
|
213 endif
|
|
214
|
|
215 MAINLIB := $(BINDIR)/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
|
|
216
|
|
217 TESTSRCS := test/test_sdlsound.c
|
|
218
|
|
219 MAINSRCS := SDL_sound.c
|
|
220
|
|
221 ifeq ($(strip $(use_decoder_raw)),true)
|
|
222 MAINSRCS += decoders/raw.c
|
|
223 CFLAGS += -DSOUND_SUPPORTS_RAW
|
|
224 endif
|
|
225
|
|
226 ifeq ($(strip $(use_decoder_voc)),true)
|
|
227 MAINSRCS += archivers/voc.c
|
|
228 CFLAGS += -DSOUND_SUPPORTS_VOC
|
|
229 endif
|
|
230
|
|
231 #ifeq ($(strip $(cygwin)),true)
|
|
232 # MAINSRCS += platform/win32.c
|
|
233 # CFLAGS += -DWIN32
|
|
234 #else
|
|
235 # MAINSRCS += platform/unix.c
|
|
236 #endif
|
|
237
|
|
238 TESTEXE := $(BINDIR)/test_sdlsound$(EXE_EXT)
|
|
239
|
|
240 # Rule for getting list of objects from source
|
|
241 MAINOBJS1 := $(MAINSRCS:.c=.o)
|
|
242 MAINOBJS2 := $(MAINOBJS1:.cpp=.o)
|
|
243 MAINOBJS3 := $(MAINOBJS2:.asm=.o)
|
|
244 MAINOBJS := $(foreach f,$(MAINOBJS3),$(BINDIR)/$(f))
|
|
245 MAINSRCS := $(foreach f,$(MAINSRCS),$(SRCDIR)/$(f))
|
|
246
|
|
247 TESTOBJS1 := $(TESTSRCS:.c=.o)
|
|
248 TESTOBJS2 := $(TESTOBJS1:.cpp=.o)
|
|
249 TESTOBJS3 := $(TESTOBJS2:.asm=.o)
|
|
250 TESTOBJS := $(foreach f,$(TESTOBJS3),$(BINDIR)/$(f))
|
|
251 TESTSRCS := $(foreach f,$(TESTSRCS),$(SRCDIR)/$(f))
|
|
252
|
|
253 CLEANUP = $(wildcard *.exe) $(wildcard *.obj) \
|
|
254 $(wildcard $(BINDIR)/*.exe) $(wildcard $(BINDIR)/*.obj) \
|
|
255 $(wildcard *~) $(wildcard *.err) \
|
|
256 $(wildcard .\#*) core
|
|
257
|
|
258
|
|
259 #-----------------------------------------------------------------------------#
|
|
260 # Rules.
|
|
261 #-----------------------------------------------------------------------------#
|
|
262
|
|
263 # Rules for turning source files into .o files
|
|
264 $(BINDIR)/%.o: $(SRCDIR)/%.cpp
|
|
265 $(CC) -c -o $@ $< $(CFLAGS)
|
|
266
|
|
267 $(BINDIR)/%.o: $(SRCDIR)/%.c
|
|
268 $(CC) -c -o $@ $< $(CFLAGS)
|
|
269
|
|
270 $(BINDIR)/%.o: $(SRCDIR)/%.asm
|
|
271 $(ASM) $(ASMFLAGS) -o $@ $<
|
|
272
|
|
273 .PHONY: all clean distclean listobjs install showcfg showflags
|
|
274
|
|
275 all: $(BINDIR) $(EXTRABUILD) $(MAINLIB) $(TESTEXE)
|
|
276
|
|
277 $(MAINLIB) : $(BINDIR) $(MAINOBJS)
|
|
278 $(LINKER) -o $(MAINLIB) $(SHAREDFLAGS) $(MAINOBJS) $(LDFLAGS)
|
|
279
|
|
280 $(TESTEXE) : $(MAINLIB) $(TESTOBJS)
|
|
281 $(LINKER) -o $(TESTEXE) $(TESTLDFLAGS) $(TESTOBJS) -L$(BINDIR) -l$(strip $(PUREBASELIBNAME)) $(LDFLAGS)
|
|
282
|
|
283
|
|
284 install: all
|
|
285 rm -f $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERMAJOR)).$(strip $(VERMINOR)).*
|
|
286 mkdir -p $(install_prefix)/bin
|
|
287 mkdir -p $(install_prefix)/lib
|
|
288 mkdir -p $(install_prefix)/include
|
|
289 cp $(SRCDIR)/SDL_sound.h $(install_prefix)/include
|
|
290 cp $(TESTEXE) $(install_prefix)/bin
|
|
291 ifeq ($(strip $(cygwin)),true)
|
|
292 cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
|
|
293 else
|
|
294 cp $(MAINLIB) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
|
|
295 ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT))
|
|
296 ln -sf $(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL)) $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERMAJOR))
|
|
297 chmod 0755 $(install_prefix)/lib/$(strip $(BASELIBNAME))$(strip $(LIB_EXT)).$(strip $(VERFULL))
|
|
298 chmod 0644 $(install_prefix)/include/SDL_sound.h
|
|
299 endif
|
|
300
|
|
301 $(BINDIR):
|
|
302 mkdir -p $(BINDIR)
|
|
303 mkdir -p $(BINDIR)/decoders
|
|
304 mkdir -p $(BINDIR)/platform
|
|
305 mkdir -p $(BINDIR)/test
|
|
306
|
|
307 distclean: clean
|
|
308
|
|
309 clean:
|
|
310 rm -f $(CLEANUP)
|
|
311 rm -rf $(BINDIR)
|
|
312
|
|
313 listobjs:
|
|
314 @echo SOURCES:
|
|
315 @echo $(MAINSRCS)
|
|
316 @echo
|
|
317 @echo OBJECTS:
|
|
318 @echo $(MAINOBJS)
|
|
319 @echo
|
|
320 @echo BINARIES:
|
|
321 @echo $(MAINLIB)
|
|
322
|
|
323 showcfg:
|
|
324 @echo "Compiler : $(CC)"
|
|
325 @echo "Using CygWin : $(cygwin)"
|
|
326 @echo "Debugging : $(debugging)"
|
|
327 @echo "ASM flag : $(use_asm)"
|
|
328 @echo "SDL_sound version : $(VERFULL)"
|
|
329 @echo "Building DLLs : $(build_dll)"
|
|
330 @echo "Install prefix : $(install_prefix)"
|
|
331 @echo "Supports .RAW : $(use_decoder_raw)"
|
|
332 @echo "Supports .VOC : $(use_decoder_voc)"
|
|
333
|
|
334 showflags:
|
|
335 @echo 'CFLAGS : $(CFLAGS)'
|
|
336 @echo 'LDFLAGS : $(LDFLAGS)'
|
|
337
|
|
338
|
|
339 #-----------------------------------------------------------------------------#
|
|
340 # This section is pretty much just for Ryan's use to make distributions.
|
|
341 # You Probably Should Not Touch.
|
|
342 #-----------------------------------------------------------------------------#
|
|
343
|
|
344 # These are the files needed in a binary distribution, regardless of what
|
|
345 # platform is being used.
|
|
346 BINSCOMMON := LICENSE CHANGELOG SDL_sound.h
|
|
347
|
|
348 .PHONY: package msbins win32bins nocygwin
|
|
349 package: clean
|
|
350 cd .. ; mv SDL_sound SDL_sound-$(VERFULL) ; tar -cyvvf ./SDL_sound-$(VERFULL).tar.bz2 --exclude="*CVS*" SDL_sound-$(VERFULL) ; mv SDL_sound-$(VERFULL) SDL_sound
|
|
351
|
|
352
|
|
353 ifeq ($(strip $(cygwin)),true)
|
|
354 msbins: win32bins
|
|
355
|
|
356 win32bins: clean all
|
|
357 cp $(SDL_LIB_DIR)/SDL.dll .
|
|
358 echo -e "\r\n\r\n\r\nHEY YOU.\r\n\r\n\r\nTake a look at README-win32bins.txt FIRST.\r\n\r\n\r\n--ryan. (icculus@clutteredmind.org)\r\n\r\n" |zip -9rz ../SDL_sound-win32bins-$(shell date +%m%d%Y).zip $(MAINLIB) SDL.dll $(EXTRAPACKAGELIBS) README-win32bins.txt
|
|
359
|
|
360 else
|
|
361
|
|
362 msbins: nocygwin
|
|
363 win32bins: nocygwin
|
|
364
|
|
365 nocygwin:
|
|
366 @echo This must be done on a Windows box in the Cygwin environment.
|
|
367
|
|
368 endif
|
|
369
|
|
370 #-----------------------------------------------------------------------------#
|
|
371 # That's all, folks.
|
|
372 #-----------------------------------------------------------------------------#
|
|
373
|
|
374 # end of Makefile ...
|