Don't add duplicate tags
[cmus.git] / configure
blob90022ca837a7679432a35e13455e31796ad2146a
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 check_library MIKMOD "" "-lmikmod"
84 return $?
87 check_modplug()
89 pkg_config MODPLUG "libmodplug" "-I/usr/include/libmodplug" "-lmodplug -lstdc++ -lm"
90 return $?
93 check_vorbis()
95 if test "$CONFIG_TREMOR" = y
96 then
97 pkg_config VORBIS "vorbisidec" "" "-lvorbisidec -lm"
98 return $?
99 else
100 pkg_config VORBIS "vorbisfile" "" "-lvorbisfile -lvorbis -lm -logg"
101 return $?
105 check_alsa()
107 # the alsa.pc file should be always available
108 pkg_config ALSA "alsa >= 1.0.11"
109 return $?
112 check_ao()
114 pkg_config AO "ao" "" "-lao"
115 return $?
118 check_arts()
120 app_config ARTS artsc-config
121 return $?
124 check_oss()
126 case `uname -s` in
127 Linux|*FreeBSD)
129 *BSD)
130 check_library OSS "" "-lossaudio"
131 return $?
134 # unknown
136 esac
138 OSS_CFLAGS=""
139 OSS_LIBS=""
140 msg_checking "for header <sys/soundcard.h>"
141 if test -f /usr/include/sys/soundcard.h
142 then
143 msg_result "yes"
144 makefile_vars OSS_CFLAGS OSS_LIBS
145 return 0
146 else
147 msg_result "no"
149 return 1
152 check_sun()
154 msg_checking "for header <sys/audioio.h>"
155 if test -f /usr/include/sys/audioio.h
156 then
157 msg_result "yes"
158 return 0
159 else
160 msg_result "no"
161 return 1
165 check_waveout()
167 case `uname -s` in
168 CYGWIN*)
169 check_library WAVEOUT "" "-lwinmm"
170 return $?
171 esac
172 return 1
175 check_mp4()
177 check_header faad.h &&
178 check_library MP4 "" "-lmp4v2 -lfaad -lm"
179 return $?
182 check_aac()
184 check_header faad.h &&
185 check_library AAC "" "-lfaad -lm"
186 return $?
189 check_ffmpeg()
191 pkg_config FFMPEG "libavformat"
192 return $?
195 # defaults
196 prefix=/usr/local
197 DEBUG=1
198 CONFIG_TREMOR=n
199 CONFIG_MIKMOD=n
200 # unset CONFIG_* variables: if check succeeds 'y', otherwise 'n'
202 USAGE="
203 Options:
204 prefix Installation prefix [$prefix]
205 bindir User executables [\$prefix/bin]
206 datadir Read-only data [\$prefix/share]
207 libdir Libraries [\$prefix/lib]
208 mandir Man pages [\$datadir/man]
209 DEBUG Debugging level (0-2) [$DEBUG]
211 Optional Features: y/n
212 CONFIG_FLAC Free Lossless Audio Codec (.flac, .fla) [auto]
213 CONFIG_MAD MPEG Audio Decoder (.mp3, .mp2, streams) [auto]
214 CONFIG_MODPLUG libmodplug (.mod, .x3m, ...) [auto]
215 CONFIG_MIKMOD libmikmod (.mod, .x3m, ...) [n]
216 CONFIG_MPC libmpcdec (Musepack .mpc, .mpp, .mp+) [auto]
217 CONFIG_VORBIS Ogg/Vorbis (.ogg, application/ogg, audio/x-ogg) [auto]
218 CONFIG_TREMOR Use Tremor as Ogg/Vorbis input plugin [n]
219 CONFIG_WAV WAV [y]
220 CONFIG_MP4 MPEG-4 AAC (.mp4, .m4a, .m4b) [auto]
221 CONFIG_AAC AAC (.aac, audio/aac, audio/aacp) [auto]
222 CONFIG_FFMPEG FFMPEG (.shn, .wma) [auto]
223 CONFIG_ALSA ALSA [auto]
224 CONFIG_AO Libao cross-platform audio library [auto]
225 CONFIG_ARTS ARTS [auto]
226 CONFIG_OSS Open Sound System [auto]
227 CONFIG_SUN Sun Audio [auto]
228 CONFIG_WAVEOUT Windows Wave Out [auto]
230 Also many standard variables like CC are recognized."
232 parse_command_line "$@"
234 case $DEBUG in
235 [0-2])
238 die "DEBUG must be 0-2"
240 esac
242 var_default bindir "${prefix}/bin"
243 var_default datadir "${prefix}/share"
244 var_default libdir "${prefix}/lib"
245 var_default mandir "${datadir}/man"
247 check check_cc
248 check check_cflags
249 check check_cc_depgen
250 check check_endianness
251 check check_compat
252 check check_dl
253 check check_pthread
254 check check_ncurses
255 check check_iconv
257 check check_flac CONFIG_FLAC
258 check check_mad CONFIG_MAD
259 check check_mikmod CONFIG_MIKMOD
260 check check_modplug CONFIG_MODPLUG
261 check check_mpc CONFIG_MPC
262 check check_vorbis CONFIG_VORBIS
263 check check_mp4 CONFIG_MP4
264 check check_aac CONFIG_AAC
265 check check_ffmpeg CONFIG_FFMPEG
266 # nothing to check, just validate the variable values
267 check true CONFIG_TREMOR
268 check true CONFIG_WAV
269 check check_alsa CONFIG_ALSA
270 check check_ao CONFIG_AO
271 check check_arts CONFIG_ARTS
272 check check_oss CONFIG_OSS
273 check check_sun CONFIG_SUN
274 check check_waveout CONFIG_WAVEOUT
276 test "$WORDS_BIGENDIAN" = y && CFLAGS="${CFLAGS} -DWORDS_BIGENDIAN"
278 DATADIR="$datadir"
279 LIBDIR="$libdir"
281 config_header config/datadir.h DATADIR
282 config_header config/libdir.h LIBDIR
283 config_header config/debug.h DEBUG
284 config_header config/tremor.h CONFIG_TREMOR
286 makefile_vars bindir datadir libdir mandir
287 makefile_vars CONFIG_FLAC CONFIG_MAD CONFIG_MIKMOD CONFIG_MODPLUG CONFIG_MPC CONFIG_VORBIS CONFIG_WAV CONFIG_MP4 CONFIG_AAC CONFIG_FFMPEG
288 makefile_vars CONFIG_ALSA CONFIG_AO CONFIG_ARTS CONFIG_OSS CONFIG_SUN CONFIG_WAVEOUT
290 generate_config_mk