1dnl -*- m4 -*-
2dnl
3dnl madplay - MPEG audio decoder and player
4dnl Copyright (C) 2000-2004 Robert Leslie
5dnl
6dnl This program is free software; you can redistribute it and/or modify
7dnl it under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version 2 of the License, or
9dnl (at your option) any later version.
10dnl
11dnl This program is distributed in the hope that it will be useful,
12dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14dnl GNU General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl along with this program; if not, write to the Free Software
18dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19dnl
20AC_REVISION([$Id: configure.ac,v 1.17 2004/02/23 21:34:53 rob Exp $])dnl
21
22dnl Process this file with autoconf to produce a configure script.
23
24AC_INIT([MPEG audio decoder and player], [0.15.2b], [rob@mars.org], [madplay])
25AC_PREREQ(2.53)
26
27AC_CONFIG_SRCDIR([madplay.c])
28
29AM_INIT_AUTOMAKE
30
31AM_CONFIG_HEADER([config.h])
32
33dnl System type.
34
35AC_CANONICAL_HOST
36
37dnl Checks for programs.
38
39# Work-around for autoconf 2.53 bug
40case "$host" in
41    *-apple-darwin*)
42	: ${CPP="cc -E -traditional-cpp"}
43	;;
44esac
45
46AC_PROG_CC
47
48if test "$GCC" = yes
49then
50    case "$host" in
51	*-*-mingw*)
52	    case "$build" in
53		*-*-cygwin*)
54		    CPPFLAGS="$CPPFLAGS -mno-cygwin"
55		    LDFLAGS="$LDFLAGS -mno-cygwin"
56		    ;;
57	    esac
58    esac
59fi
60
61dnl Support for libtool.
62
63AC_DISABLE_SHARED
64AC_PROG_LIBTOOL
65
66AC_SUBST(LIBTOOL_DEPS)
67
68dnl Compiler options.
69
70arch=""
71debug=""
72optimize=""
73profile=""
74
75set -- $CFLAGS
76CFLAGS=""
77
78if test "$GCC" = yes
79then
80    CFLAGS="-Wall"
81fi
82
83while test $# -gt 0
84do
85    case "$1" in
86	-Wall)
87	    if test "$GCC" = yes
88	    then
89		:
90	    else
91		CFLAGS="$CFLAGS $1"
92	    fi
93	    shift
94	    ;;
95	-g)
96	    debug="-g"
97	    shift
98	    ;;
99	-mno-cygwin)
100	    shift
101	    ;;
102	-m*)
103	    arch="$arch $1"
104	    shift
105	    ;;
106	-fomit-frame-pointer)
107	    shift
108	    ;;
109	-O*|-f*)
110	    optimize="$1"
111	    shift
112	    ;;
113	*)
114	    CFLAGS="$CFLAGS $1"
115	    shift
116	    ;;
117    esac
118done
119
120if test "$GCC" = yes
121then
122    if test -z "$arch"
123    then
124	case "$host" in
125	    i386-*)           ;;
126	    i?86-*)           arch="-march=i486" ;;
127	    arm*-empeg-*)     arch="-march=armv4 -mtune=strongarm1100" ;;
128	    armv4*-*)         arch="-march=armv4 -mtune=strongarm" ;;
129	    powerpc-*)        ;;
130	    mips*-agenda-*)   arch="-mcpu=vr4100" ;;
131	    mips*-luxsonor-*) arch="-mips1 -mcpu=r3000 -Wa,-m4010" ;;
132	esac
133    fi
134
135    if test -n "$optimize"
136    then
137	: #? optimize="$optimize -funroll-loops"
138	: #? optimize="$optimize -finline-functions"
139    fi
140fi
141
142dnl Internationalization support.
143
144ALL_LINGUAS="en es fr hr no"
145
146AM_GNU_GETTEXT([use-libtool])
147AM_GNU_GETTEXT_VERSION(0.14.1)
148
149dnl Checks for header files.
150
151AC_HEADER_STDC
152AC_CHECK_HEADERS(assert.h termios.h stropts.h  \
153		 sys/types.h fcntl.h errno.h  \
154		 sys/soundcard.h machine/soundcard.h)
155
156AC_CHECK_HEADER(mad.h, [], [
157	AC_MSG_ERROR([mad.h was not found
158*** You must first install libmad before you can build this package.
159*** If libmad is already installed, you may need to use the CPPFLAGS
160*** environment variable to specify its installed location, e.g. -I<dir>.])
161])
162
163AC_CHECK_HEADER(id3tag.h, [], [
164	AC_MSG_ERROR([id3tag.h was not found
165*** You must first install libid3tag before you can build this package.
166*** If libid3tag is already installed, you may need to use the CPPFLAGS
167*** environment variable to specify its installed location, e.g. -I<dir>.])
168])
169
170dnl Checks for typedefs, structures, and compiler characteristics.
171
172AC_C_CONST
173AC_C_INLINE
174AC_C_BIGENDIAN
175
176dnl Checks for library functions.
177
178AC_CHECK_LIB(mad, mad_decoder_run, :, [
179	AC_MSG_ERROR([libmad was not found
180*** You must first install libmad before you can build this package.
181*** If libmad is already installed, you may need to use the LDFLAGS
182*** environment variable to specify its installed location, e.g. -L<dir>.])
183])
184
185AC_CHECK_LIB(id3tag, id3_tag_parse, :, [
186	AC_MSG_ERROR([libid3tag was not found
187*** You must first install libid3tag before you can build this package.
188*** If libid3tag is already installed, you may need to use the LDFLAGS
189*** environment variable to specify its installed location, e.g. -L<dir>.])
190], [-lz])
191
192AC_FUNC_VPRINTF
193AC_CHECK_FUNCS(madvise localeconv)
194AC_REPLACE_FUNCS(strcasecmp strncasecmp)
195AC_SEARCH_LIBS(pow, m)
196AC_SEARCH_LIBS(log10, m)
197
198case "$host" in
199    *-linux*) AC_DEFINE(HAVE_MMAP) ;;
200    *)        AC_FUNC_MMAP ;;
201esac
202
203AC_MSG_CHECKING([whether to use mmap])
204AC_ARG_ENABLE(mmap, AC_HELP_STRING([--disable-mmap],
205		    [do not use mmap even if available (lower mem usage)]),
206[
207    case "$enableval" in
208	yes)
209	    AC_DEFINE(USE_MMAP, 1,
210		[Define if you have mmap() and you want to use it.])
211	    ;;
212    esac
213], [
214    AC_DEFINE(USE_MMAP)
215])
216AC_MSG_RESULT(${enable_mmap-yes})
217
218AC_CACHE_SAVE
219
220dnl Select an audio system.
221
222depend_audio=""
223ldadd_audio=""
224AC_SUBST(depend_audio)
225AC_SUBST(ldadd_audio)
226
227AC_MSG_CHECKING([for audio support])
228
229audio="unknown"
230
231want_alsa=no
232AC_ARG_WITH(alsa, AC_HELP_STRING([--with-alsa],
233		  [use Advanced Linux Sound Architecture as default]),
234[
235    case "$withval" in
236	yes)
237	    want_alsa=yes
238	    if test "$audio" = unknown
239	    then
240		audio="alsa"
241	    else
242		AC_MSG_ERROR([cannot use both --with-$audio and --with-alsa])
243	    fi
244	    ;;
245    esac
246])
247
248want_esd=yes
249AC_ARG_WITH(esd, AC_HELP_STRING([--with-esd],
250		 [use Enlightened Sound Daemon (EsounD) as default]),
251[
252    case "$withval" in
253	yes)
254	    if test "$audio" = unknown
255	    then
256		audio="esd"
257	    else
258		AC_MSG_ERROR([cannot use both --with-$audio and --with-esd])
259	    fi
260	    ;;
261	no)
262	    want_esd=no
263	    ;;
264    esac
265])
266
267dnl want_nas=yes
268dnl AC_ARG_WITH(nas, AC_HELP_STRING([--with-nas],
269dnl 		     [use Network Audio System (NAS) as default]),
270dnl [
271dnl     case "$withval" in
272dnl 	yes)
273dnl 	    if test "$audio" = unknown
274dnl 	    then
275dnl 		audio="nas"
276dnl 	    else
277dnl 		AC_MSG_ERROR([cannot use both --with-$audio and --with-nas])
278dnl 	    fi
279dnl 	    ;;
280dnl 	no)
281dnl 	    want_nas=no
282dnl 	    ;;
283dnl     esac
284dnl ])
285
286if test "$audio" = unknown
287then
288    case "$host" in
289	arm*-empeg-*) audio="empeg" ;;
290    esac
291fi
292
293dnl if test "$audio" = unknown
294dnl then
295dnl     AC_EGREP_CPP(kAudioUnitProperty_SetRenderCallback, [
296dnl # include <AudioUnit/AudioUnit.h>
297dnl ], [audio="jaguar";
298dnl     ldadd_audio="$ldadd_audio -framework AudioUnit -framework CoreServices"])
299dnl fi
300
301if test "$audio" = unknown
302then
303    AC_EGREP_CPP(SndNewChannel, [
304# include <Carbon/Carbon.h>
305], [audio="carbon"; ldadd_audio="$ldadd_audio -framework Carbon"])
306fi
307
308if test "$audio" = unknown
309then
310    AC_EGREP_CPP(waveOutOpen, [
311# include <mmsystem.h>
312], [audio="win32"; ldadd_audio="$ldadd_audio -lwinmm"])
313fi
314
315if test "$audio" = unknown
316then
317    AC_EGREP_CPP(yes, [
318# include <sys/soundcard.h>
319# if defined(OPEN_SOUND_SYSTEM) || defined(UNIX_SOUND_SYSTEM) ||  \
320    defined(VOXWARE)
321yes
322# endif
323], [audio="oss"])
324fi
325
326if test "$audio" = unknown
327then
328    AC_EGREP_CPP(yes, [
329# include <machine/soundcard.h>
330# if defined(OPEN_SOUND_SYSTEM) || defined(UNIX_SOUND_SYSTEM) ||  \
331    defined(VOXWARE)
332yes
333# endif
334], [audio="oss"])
335fi
336
337if test "$audio" = unknown
338then
339    AC_EGREP_CPP(audio_info_t, [
340# include <sys/audioio.h>
341], [audio="sun"])
342fi
343
344if test "$audio" = unknown
345then
346    AC_EGREP_CPP(yes, [
347# include <sys/asoundlib.h>
348# if defined(SND_PCM_OPEN_PLAYBACK)
349yes
350# endif
351], [audio="qnx"; ldadd_audio="$ldadd_audio -lasound"])
352fi
353
354AC_MSG_RESULT($audio)
355
356if test "$want_alsa" = yes
357then
358    AC_CHECK_LIB(asound, snd_pcm_open, have_libasound=yes, have_libasound=no)
359
360    if test "$have_libasound" = yes
361    then
362	AC_DEFINE(HAVE_LIBASOUND, 1,
363	    [Define if you have the asound library (-lasound).])
364	ldadd_audio="$ldadd_audio -lasound"
365    fi
366fi
367
368if test "$want_esd" = yes
369then
370    AC_CHECK_LIB(esd, esd_open_sound, have_libesd=yes, have_libesd=no)
371
372    if test "$have_libesd" = yes
373    then
374	AC_DEFINE(HAVE_LIBESD, 1,
375	    [Define if you have the esd library (-lesd).])
376	ldadd_audio="$ldadd_audio -lesd"
377    fi
378fi
379
380dnl if test "$want_nas" = yes
381dnl then
382dnl     AC_PATH_X
383dnl     if test "$no_x" = yes
384dnl     then
385dnl 	have_libaudio=no
386dnl     else
387dnl 	AC_CHECK_LIB(audio, AuOpenServer,
388dnl 	    have_libaudio=yes, have_libaudio=no, -L$x_libraries -lXau -lXt)
389dnl
390dnl 	if test "$have_libaudio" = yes
391dnl 	then
392dnl 	    AC_DEFINE(HAVE_LIBAUDIO)
393dnl 	    ldadd_audio="$ldadd_audio -laudio -L$x_libraries -lXau -lXt"
394dnl 	fi
395dnl     fi
396dnl fi
397
398if test "$audio" = alsa
399then
400    if test "$have_libasound" = no
401    then
402	AC_MSG_ERROR([cannot use --with-alsa because libasound was not found])
403    fi
404else
405    if test "$want_alsa" = yes && test "$have_libasound" = yes
406    then
407	depend_audio="$depend_audio audio_alsa.o"
408    fi
409fi
410
411if test "$audio" = esd
412then
413    if test "$have_libesd" = no
414    then
415	AC_MSG_ERROR([cannot use --with-esd because libesd was not found])
416    fi
417else
418    if test "$want_esd" = yes && test "$have_libesd" = yes
419    then
420	depend_audio="$depend_audio audio_esd.o"
421    fi
422fi
423
424dnl if test "$audio" = nas
425dnl then
426dnl     if test "$have_libaudio" = no
427dnl     then
428dnl 	AC_MSG_ERROR([cannot use --with-nas because libaudio was not found])
429dnl     fi
430dnl else
431dnl     if test "$want_nas" = yes && test "$have_libaudio" = yes
432dnl     then
433dnl 	depend_audio="$depend_audio audio_nas.o"
434dnl     fi
435dnl fi
436
437if test "$audio" = unknown
438then
439    AC_MSG_WARN([audio support not available; using null module])
440    AC_DEFINE(AUDIO_DEFAULT, audio_null,
441	[Define to be the name of your default audio output module.])
442else
443    AC_DEFINE_UNQUOTED(AUDIO_DEFAULT, [audio_$audio])
444
445    depend_audio="$depend_audio audio_$audio.o"
446fi
447
448dnl madplay options...
449
450AC_MSG_CHECKING([whether to enable profiling])
451AC_ARG_ENABLE(profiling, AC_HELP_STRING([--enable-profiling],
452			 [generate profiling code]),
453[
454    case "$enableval" in
455	yes) profile="-pg" ;;
456    esac
457])
458AC_MSG_RESULT(${enable_profiling-no})
459
460AC_MSG_CHECKING([whether to enable debugging])
461AC_ARG_ENABLE(debugging, AC_HELP_STRING([--enable-debugging],
462			 [enable diagnostic debugging support])
463AC_HELP_STRING([--disable-debugging],
464			 [do not enable debugging and use more optimization]),
465[
466    case "$enableval" in
467	yes)
468	    AC_DEFINE(DEBUG, 1,
469		[Define to enable diagnostic debugging support.])
470	    optimize=""
471	    ;;
472	no)
473	    if test -n "$profile"
474	    then
475    AC_MSG_ERROR([--enable-profiling and --disable-debugging are incompatible])
476	    fi
477
478	    AC_DEFINE(NDEBUG, 1,
479		[Define to disable debugging assertions.])
480	    debug=""
481	    if test "$GCC" = yes
482	    then
483		optimize="$optimize -fomit-frame-pointer"
484	    fi
485	    ;;
486    esac
487])
488AC_MSG_RESULT(${enable_debugging-default})
489
490case "$enable_debugging" in
491    yes) AC_CHECK_LIB(efence, malloc) ;;
492esac
493
494AC_MSG_CHECKING([whether to enable experimental code])
495AC_ARG_ENABLE(experimental, AC_HELP_STRING([--enable-experimental],
496			    [enable experimental code]),
497[
498    case "$enableval" in
499	yes)
500	    AC_DEFINE(EXPERIMENTAL, 1, [Define to enable experimental code.])
501	    ;;
502    esac
503])
504AC_MSG_RESULT(${enable_experimental-no})
505
506dnl Create output files.
507
508test -n "$arch"     && CFLAGS="$CFLAGS $arch"
509test -n "$debug"    && CFLAGS="$CFLAGS $debug"
510test -n "$optimize" && CFLAGS="$CFLAGS $optimize"
511test -n "$profile"  && CFLAGS="$CFLAGS $profile" LDFLAGS="$LDFLAGS $profile"
512
513AC_CONFIG_FILES([Makefile msvc++/Makefile  \
514	intl/Makefile po/Makefile.in m4/Makefile  \
515	madplay.list])
516AC_OUTPUT
517