Document Replay Gain
[cmus.git] / configure
blob0bb49c0a464fccec7d78e430b7c0e851818acbbb
1 #!/bin/sh
3 . scripts/configure.sh || exit 1
5 check_cflags()
7 check_cc_flag -std=gnu99 -pipe -Wall -Wshadow -Wcast-align -Wpointer-arith \
8 -Wwrite-strings -Wundef -Wmissing-prototypes -Wredundant-decls
10 for i in -Wdeclaration-after-statement -Wold-style-definition -Wno-pointer-sign
12 check_cc_flag $i
13 done
14 return 0
17 check_compat()
19 COMPAT_LIBS=
20 case `uname -s` in
21 SunOS)
22 # connect() etc.
23 try_link -lsocket && COMPAT_LIBS="$COMPAT_LIBS -lsocket"
25 # gethostbyname()
26 try_link -lnsl && COMPAT_LIBS="$COMPAT_LIBS -lnsl"
28 # nanosleep()
29 if try_link -lrt
30 then
31 COMPAT_LIBS="$COMPAT_LIBS -lrt"
32 elif try_link -lposix4
33 then
34 COMPAT_LIBS="$COMPAT_LIBS -lposix4"
37 CYGWIN*)
38 CONFIG_CYGWIN=y
39 makefile_vars CONFIG_CYGWIN
40 esac
41 makefile_vars COMPAT_LIBS
44 check_ncurses()
46 if check_library NCURSES "" -lncursesw
47 then
48 widechars=y
49 return 0
51 if check_library NCURSES "" -lncurses || check_library NCURSES "" -lcurses
52 then
53 widechars=n
54 msg_error "Your ncurses does not support wide characters!"
55 msg_error "Install ncursesw if you need wide character support,"
56 msg_error "you can ignore this warning otherwise."
57 return 0
59 return 1
62 check_mpc()
64 check_library MPC "" "-lmpcdec"
65 return $?
68 check_flac()
70 check_library FLAC "" "-lFLAC -lm" && return 0
71 check_library FLAC "" "-lFLAC -lvorbisfile -lm"
72 return $?
75 check_mad()
77 pkg_config MAD "mad" "" "-lmad -lm"
78 return $?
81 check_mikmod()
83 app_config MIKMOD libmikmod-config && return 0
84 # mikmod is linked against pthread
85 check_library MIKMOD "$PTHREAD_CFLAGS" "-lmikmod $PTHREAD_LIBS"
86 return $?
89 check_modplug()
91 pkg_config MODPLUG "libmodplug" "-I/usr/include/libmodplug" "-lmodplug -lstdc++ -lm"
92 return $?
95 check_vorbis()
97 if test "$CONFIG_TREMOR" = y
98 then
99 pkg_config VORBIS "vorbisidec" "" "-lvorbisidec -lm"
100 return $?
101 else
102 pkg_config VORBIS "vorbisfile" "" "-lvorbisfile -lvorbis -lm -logg"
103 return $?
107 check_wavpack()
109 pkg_config WAVPACK "wavpack" "" "-lwavpack"
110 return $?
113 check_alsa()
115 # the alsa.pc file should be always available
116 pkg_config ALSA "alsa >= 1.0.11"
117 return $?
120 check_ao()
122 pkg_config AO "ao" "" "-lao"
123 return $?
126 check_arts()
128 app_config ARTS artsc-config
129 return $?
132 check_oss()
134 case `uname -s` in
135 Linux|*FreeBSD)
137 *BSD)
138 check_library OSS "" "-lossaudio"
139 return $?
142 # unknown
144 esac
146 OSS_CFLAGS=""
147 OSS_LIBS=""
148 msg_checking "for header <sys/soundcard.h>"
149 if test -f /usr/include/sys/soundcard.h
150 then
151 msg_result "yes"
152 makefile_vars OSS_CFLAGS OSS_LIBS
153 return 0
154 else
155 msg_result "no"
157 return 1
160 check_sun()
162 msg_checking "for header <sys/audioio.h>"
163 if test -f /usr/include/sys/audioio.h
164 then
165 msg_result "yes"
166 return 0
167 else
168 msg_result "no"
169 return 1
173 check_waveout()
175 case `uname -s` in
176 CYGWIN*)
177 check_library WAVEOUT "" "-lwinmm"
178 return $?
179 esac
180 return 1
183 check_mp4()
185 check_header faad.h &&
186 check_library MP4 "" "-lmp4v2 -lfaad -lm"
187 return $?
190 check_aac()
192 check_header faad.h &&
193 check_library AAC "" "-lfaad -lm"
194 return $?
197 check_ffmpeg()
199 pkg_config FFMPEG "libavformat"
200 return $?
203 # defaults
204 prefix=/usr/local
205 DEBUG=1
206 CONFIG_TREMOR=n
207 CONFIG_MIKMOD=n
208 # unset CONFIG_* variables: if check succeeds 'y', otherwise 'n'
210 USAGE="
211 Options:
212 prefix Installation prefix [$prefix]
213 bindir User executables [\$prefix/bin]
214 datadir Read-only data [\$prefix/share]
215 libdir Libraries [\$prefix/lib]
216 mandir Man pages [\$datadir/man]
217 exampledir Examples [\$datadir/doc/cmus/examples]
218 DEBUG Debugging level (0-2) [$DEBUG]
220 Optional Features: y/n
221 CONFIG_FLAC Free Lossless Audio Codec (.flac, .fla) [auto]
222 CONFIG_MAD MPEG Audio Decoder (.mp3, .mp2, streams) [auto]
223 CONFIG_MODPLUG libmodplug (.mod, .x3m, ...) [auto]
224 CONFIG_MIKMOD libmikmod (.mod, .x3m, ...) [n]
225 CONFIG_MPC libmpcdec (Musepack .mpc, .mpp, .mp+) [auto]
226 CONFIG_VORBIS Ogg/Vorbis (.ogg, application/ogg, audio/x-ogg) [auto]
227 CONFIG_TREMOR Use Tremor as Ogg/Vorbis input plugin [n]
228 CONFIG_WAV WAV [y]
229 CONFIG_WAVPACK WavPack (.wv, audio/x-wavpack) [auto]
230 CONFIG_MP4 MPEG-4 AAC (.mp4, .m4a, .m4b) [auto]
231 CONFIG_AAC AAC (.aac, audio/aac, audio/aacp) [auto]
232 CONFIG_FFMPEG FFMPEG (.shn, .wma) [auto]
233 CONFIG_ALSA ALSA [auto]
234 CONFIG_AO Libao cross-platform audio library [auto]
235 CONFIG_ARTS ARTS [auto]
236 CONFIG_OSS Open Sound System [auto]
237 CONFIG_SUN Sun Audio [auto]
238 CONFIG_WAVEOUT Windows Wave Out [auto]
240 Also many standard variables like CC are recognized."
242 parse_command_line "$@"
244 case $DEBUG in
245 [0-2])
248 die "DEBUG must be 0-2"
250 esac
252 var_default bindir "${prefix}/bin"
253 var_default datadir "${prefix}/share"
254 var_default libdir "${prefix}/lib"
255 var_default mandir "${datadir}/man"
256 var_default exampledir "${datadir}/doc/cmus/examples"
258 check check_cc
259 check check_cflags
260 check check_cc_depgen
261 check check_endianness
262 check check_compat
263 check check_dl
264 check check_pthread
265 check check_ncurses
266 check check_iconv
268 check check_flac CONFIG_FLAC
269 check check_mad CONFIG_MAD
270 check check_mikmod CONFIG_MIKMOD
271 check check_modplug CONFIG_MODPLUG
272 check check_mpc CONFIG_MPC
273 check check_vorbis CONFIG_VORBIS
274 check check_wavpack CONFIG_WAVPACK
275 check check_mp4 CONFIG_MP4
276 check check_aac CONFIG_AAC
277 check check_ffmpeg CONFIG_FFMPEG
278 # nothing to check, just validate the variable values
279 check true CONFIG_TREMOR
280 check true CONFIG_WAV
281 check check_alsa CONFIG_ALSA
282 check check_ao CONFIG_AO
283 check check_arts CONFIG_ARTS
284 check check_oss CONFIG_OSS
285 check check_sun CONFIG_SUN
286 check check_waveout CONFIG_WAVEOUT
288 test "$WORDS_BIGENDIAN" = y && CFLAGS="${CFLAGS} -DWORDS_BIGENDIAN"
290 DATADIR="$datadir"
291 LIBDIR="$libdir"
293 config_header config/datadir.h DATADIR
294 config_header config/libdir.h LIBDIR
295 config_header config/debug.h DEBUG
296 config_header config/tremor.h CONFIG_TREMOR
298 makefile_vars bindir datadir libdir mandir exampledir
299 makefile_vars CONFIG_FLAC CONFIG_MAD CONFIG_MIKMOD CONFIG_MODPLUG CONFIG_MPC CONFIG_VORBIS CONFIG_WAVPACK CONFIG_WAV CONFIG_MP4 CONFIG_AAC CONFIG_FFMPEG
300 makefile_vars CONFIG_ALSA CONFIG_AO CONFIG_ARTS CONFIG_OSS CONFIG_SUN CONFIG_WAVEOUT
302 generate_config_mk