1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.53)
3
4AC_INIT([normalize],[0.7.7])
5AC_CONFIG_SRCDIR(src/normalize.c)
6
7AC_CONFIG_AUX_DIR(config)
8AC_CONFIG_FILES(config/Makefile)
9
10AM_INIT_AUTOMAKE
11AM_CONFIG_HEADER(config.h)
12
13AC_CANONICAL_HOST
14AC_PROG_CC
15AC_ISC_POSIX
16AC_PROG_INSTALL
17AC_PROG_LN_S
18
19AC_DOSFILE
20
21dnl Checks for headers
22AC_HEADER_STDC([])
23AC_CHECK_HEADERS([string.h math.h ctype.h fcntl.h unistd.h byteswap.h sys/types.h sys/stat.h sys/mman.h locale.h stdint.h inttypes.h errno.h])
24
25dnl Checks for typedefs, structures, and compiler characteristics.
26AC_C_CONST
27AC_C_INLINE
28AC_TYPE_OFF_T
29AC_TYPE_SIZE_T
30if test "$cross_compiling" = "yes"; then
31    dnl Try to guess the endianness from the host cpu type
32    case "$host_cpu" in
33	i?86 | alpha ) ENDIAN=little;;
34	*) ENDIAN=big; AC_DEFINE(WORDS_BIGENDIAN);;
35    esac
36    AC_MSG_WARN([I'm guessing that the target machine is ]$ENDIAN[-endian])
37else
38    AC_C_BIGENDIAN
39fi
40
41dnl Checks for libraries
42AC_CHECK_LIB(m, sqrt, , AC_MSG_ERROR([You don't seem to have a math library!]))
43AC_CHECK_FUNCS(strerror strtod strchr memcpy ftruncate)
44
45dnl Word sizes...
46if test x"$cross_compiling" = xyes -a x"$ac_cv_sizeof_long" = x; then
47  # if cross-compiling, with no cached values, just assume something common.
48  ac_cv_sizeof_char=1
49  ac_cv_sizeof_short=2
50  ac_cv_sizeof_int=4
51  ac_cv_sizeof_long=4
52  AC_MSG_WARN([Cross-compiling, so cannot check type sizes; assuming short=2, int=4, long=4])
53fi
54AC_CHECK_SIZEOF(char)
55AC_CHECK_SIZEOF(short)
56AC_CHECK_SIZEOF(int)
57AC_CHECK_SIZEOF(long)
58SIZEOF_CHAR=$ac_cv_sizeof_char
59SIZEOF_SHORT=$ac_cv_sizeof_short
60SIZEOF_INT=$ac_cv_sizeof_int
61SIZEOF_LONG=$ac_cv_sizeof_long
62
63AH_TEMPLATE([__TYPE8__], [Define to the 8-bit integer type on your system.])
64AH_TEMPLATE([__TYPE16__], [Define to the 16-bit integer type on your system.])
65AH_TEMPLATE([__TYPE32__], [Define to the 32-bit integer type on your system.])
66
67AC_MSG_CHECKING([for an 8-bit type])
68if test $SIZEOF_CHAR -eq 1; then
69    AC_DEFINE(__TYPE8__, char)
70    TYPE8=char
71elif test $SIZEOF_SHORT -eq 1; then
72    AC_DEFINE(__TYPE8__, short)
73    TYPE8=short
74elif test $SIZEOF_INT -eq 1; then
75    AC_DEFINE(__TYPE8__, int)
76    TYPE8=int
77elif test $SIZEOF_LONG -eq 1; then
78    AC_DEFINE(__TYPE8__, long)
79    TYPE8=long
80else
81    AC_MSG_RESULT([not found])
82    AC_MSG_ERROR([I can't seem to find an 8-bit integer type!])
83fi
84AC_MSG_RESULT($TYPE8)
85
86AC_MSG_CHECKING([for a 16-bit type])
87if test $SIZEOF_CHAR -eq 2; then
88    AC_DEFINE(__TYPE16__, char)
89    TYPE16=char
90elif test $SIZEOF_SHORT -eq 2; then
91    AC_DEFINE(__TYPE16__, short)
92    TYPE16=short
93elif test $SIZEOF_INT -eq 2; then
94    AC_DEFINE(__TYPE16__, int)
95    TYPE16=int
96elif test $SIZEOF_LONG -eq 2; then
97    AC_DEFINE(__TYPE16__, long)
98    TYPE16=long
99else
100    AC_MSG_RESULT([not found])
101    AC_MSG_ERROR([I can't seem to find a 16-bit integer type!])
102fi
103AC_MSG_RESULT($TYPE16)
104
105AC_MSG_CHECKING([for a 32-bit type])
106if test $SIZEOF_CHAR -eq 4; then
107    AC_DEFINE(__TYPE32__, char)
108    TYPE32=char
109elif test $SIZEOF_SHORT -eq 4; then
110    AC_DEFINE(__TYPE32__, short)
111    TYPE32=short
112elif test $SIZEOF_INT -eq 4; then
113    AC_DEFINE(__TYPE32__, int)
114    TYPE32=int
115elif test $SIZEOF_LONG -eq 4; then
116    AC_DEFINE(__TYPE32__, long)
117    TYPE32=long
118else
119    AC_MSG_RESULT([not found])
120    AC_MSG_ERROR([I can't seem to find a 32-bit integer type!])
121fi
122AC_MSG_RESULT($TYPE32)
123
124dnl  Solaris puts int8_t, etc in inttypes.h for some reason,
125dnl  and cygwin puts it in sys/types.h
126AC_CHECK_TYPES([int8_t, int16_t, int32_t, uint8_t, uint16_t, uint32_t],,,
127[#if HAVE_STDINT_H
128# include <stdint.h>
129#endif
130#if HAVE_INTTYPES_H
131# include <inttypes.h>
132#endif
133#if HAVE_SYS_TYPES_H
134# include <sys/types.h>
135#endif]
136)
137
138AH_BOTTOM(
139[#if !HAVE_INT8_T
140typedef signed __TYPE8__ int8_t;
141#endif
142#if !HAVE_INT16_T
143typedef signed __TYPE16__ int16_t;
144#endif
145#if !HAVE_INT32_T
146typedef signed __TYPE32__ int32_t;
147#endif
148#if !HAVE_UINT8_T
149typedef unsigned __TYPE8__ uint8_t;
150#endif
151#if !HAVE_UINT16_T
152typedef unsigned __TYPE16__ uint16_t;
153#endif
154#if !HAVE_UINT32_T
155typedef unsigned __TYPE32__ uint32_t;
156#endif])
157
158AC_CACHE_SAVE
159
160dnl *** Helper programs used by the normalize-mp3 script ***
161AC_ARG_ENABLE(helper-search,
162    AC_HELP_STRING([--disable-helper-search],
163		   [do not look for helper programs]),
164    [ case "$enableval" in
165	  yes) do_helper_search=true ;;
166	  no) do_helper_search=false ;;
167	  *) AC_MSG_ERROR(bad value $withval for --enable-helper-search) ;;
168      esac ],
169    do_helper_search=true)
170
171AC_PATH_PROG(PERL, perl, /usr/bin/perl)
172if test x$do_helper_search = xtrue; then
173    AC_CHECK_PROGS(MP3DECODE, madplay mpg123, [])
174    AC_CHECK_PROGS(MP3ENCODE, lame notlame bladeenc, [])
175dnl AC_CHECK_PROGS(MP3INFO, mp3info id3cp, [])
176    AC_CHECK_PROGS(OGGDECODE, oggdec ogg123, [])
177    AC_CHECK_PROGS(OGGENCODE, oggenc, [])
178    AC_CHECK_PROGS(VORBISCOMMENT, vorbiscomment, [])
179    AC_CHECK_PROGS(FLACDECODE, flac, [])
180    AC_CHECK_PROGS(FLACENCODE, flac, [])
181    AC_CHECK_PROGS(METAFLAC, metaflac, [])
182    if test x$MP3DECODE = xmpg123; then
183	MP3DECODE="$MP3DECODE -q -w %w %m"
184    else
185	MP3DECODE="$MP3DECODE -q -o %w %m"
186    fi
187    if test x$MP3ENCODE = xlame -o x$MP3ENCODE = xnotlame; then
188	MP3ENCODE="$MP3ENCODE --quiet -h -b %b %w %m"
189    else
190	MP3ENCODE="$MP3ENCODE -quiet %w %m"
191    fi
192    if test x$OGGDECODE = xoggdec; then
193	OGGDECODE="$OGGDECODE -Q -o %w %m"
194    else
195	OGGDECODE="$OGGDECODE -q -d wav -f %w %m"
196    fi
197    if test x$OGGENCODE != x; then
198	OGGENCODE="$OGGENCODE -Q -b %b -o %m %w"
199    fi
200    if test x$FLACDECODE != x; then
201	FLACDECODE="$FLACDECODE -s -d -o %w %m"
202    fi
203    if test x$FLACENCODE != x; then
204	FLACENCODE="$FLACENCODE -s -o %m %w"
205    fi
206fi
207
208dnl *** lookup table enable/disable ***
209AH_TEMPLATE([USE_LOOKUPTABLE],
210	    [Define if you want to use lookup tables
211	     (faster, but uses memory).])
212AC_ARG_ENABLE(lookup-table,
213    AC_HELP_STRING([--disable-lookup-table],
214		   [do not use lookup tables (saves memory, but slow)]),
215    [ case "$enableval" in
216	  yes) AC_DEFINE(USE_LOOKUPTABLE) ;;
217	  no) ;;
218	  *) AC_MSG_ERROR(bad value $withval for --with-lookuptable) ;;
219      esac ],
220    AC_DEFINE(USE_LOOKUPTABLE))
221
222dnl *** Stuff for xmms plugin ***
223have_xmms=true
224AM_PATH_GLIB(1.2.2, , [ have_xmms=false ])
225AM_PATH_GTK(1.2.2, , [ have_xmms=false ], gthread)
226AM_PATH_XMMS(1.0.0, , [ have_xmms=false ])
227AM_DISABLE_STATIC
228AM_PROG_LIBTOOL
229AC_ARG_ENABLE(xmms,
230    AC_HELP_STRING([--enable-xmms],
231		   [build the volume adjust plugin for xmms (default yes)]),
232    [ case "$enableval" in
233	  yes) enable_xmms=true ;;
234	  no) enable_xmms=false ;;
235	  *) AC_MSG_ERROR(bad value $enableval for --enable-xmms) ;;
236      esac ])
237
238use_xmms=false
239if test x$enable_xmms != xfalse; then
240    if test x$have_xmms = xtrue; then
241	use_xmms=true
242	PLUGINS="xmms-rva $PLUGINS"
243    elif test x$enable_xmms = xtrue; then
244	AC_MSG_ERROR([--enable-xmms specified, but xmms not found])
245    fi
246fi
247AC_SUBST(PLUGINS)
248
249
250dnl *** Stuff for audiofile library ***
251dnl v0.2.1 and before have bugs with 24-bit LE files
252AM_PATH_AUDIOFILE([ 0.2.2 ], [ have_audiofile=true ])
253dnl AC_CHECK_LIB(audiofile, afSetVirtualSampleFormat, have_audiofile=true)
254AH_TEMPLATE([USE_AUDIOFILE],
255	    [Define if you want to use the audiofile library.])
256AC_ARG_WITH(audiofile,
257    AC_HELP_STRING([--with-audiofile],
258		   [use the audiofile library (default yes)]),
259    [ case "$withval" in
260	  no) with_audiofile=false ;;
261	  *) with_audiofile=true ;;
262      esac ])
263
264use_audiofile=false
265if test x$with_audiofile != xfalse; then
266    if test x$have_audiofile = xtrue; then
267	AC_DEFINE(USE_AUDIOFILE)
268	use_audiofile=true
269dnl	AUDIOFILELIBS="-laudiofile"
270    elif test x$with_audiofile = xtrue; then
271	AC_MSG_ERROR([--with-audiofile specified, but audiofile library not found])
272    fi
273fi
274dnl AC_SUBST(AUDIOFILELIBS)
275test x$use_audiofile = xfalse && AUDIOFILE_LIBS=
276test x$use_audiofile = xfalse && AUDIOFILE_CFLAGS=
277AM_CONDITIONAL(AUDIOFILE, test x$use_audiofile = xtrue)
278
279
280dnl *** Stuff for mad mpeg audio decoder library ***
281AH_TEMPLATE([USE_MAD],
282	    [Define if you want to use the mad mpeg audio decoder library.])
283AC_ARG_WITH(mad-prefix,
284    AC_HELP_STRING([--with-mad-prefix=PFX],
285		   [prefix where MAD library is installed]),
286    [ CPPFLAGS="$CPPFLAGS -I$withval/include"
287      LDFLAGS="$LDFLAGS -L$withval/lib"
288      with_mad=true ])
289AC_ARG_WITH(mad,
290    AC_HELP_STRING([--with-mad],
291		   [use the mad mpeg audio library (default yes)]),
292    [ case "$withval" in
293	  no) with_mad=false ;;
294	  *) with_mad=true ;;
295      esac ])
296AC_CHECK_LIB(mad, mad_decoder_init, have_mad=true)
297
298use_mad=false
299if test x$with_mad != xfalse; then
300    if test x$have_mad = xtrue; then
301	AC_DEFINE(USE_MAD)
302	use_mad=true
303	MADLIBS="-lmad"
304    elif test x$with_mad = xtrue; then
305	AC_MSG_ERROR([--with-mad specified, but mad library not found])
306    fi
307fi
308AC_SUBST(MADLIBS)
309AM_CONDITIONAL(MAD, test x$use_mad = xtrue)
310
311dnl *** make the name "normalize-audio" like the debian folks like it ***
312AC_ARG_ENABLE(longer-name,
313    AC_HELP_STRING([--enable-longer-name],
314		   [name the binary "normalize-audio" instead of "normalize"]),
315    [ case "$enableval" in
316	  yes) NORMALIZE_BIN=normalize-audio ;;
317	  no) NORMALIZE_BIN=normalize ;;
318	  *) AC_MSG_ERROR(bad value $withval for --enable-longer-name) ;;
319      esac ],
320    NORMALIZE_BIN=normalize)
321AC_SUBST(NORMALIZE_BIN)
322
323AM_GNU_GETTEXT([external])
324
325AC_CONFIG_FILES(src/normalize-mp3, [chmod +x src/normalize-mp3])
326dnl AC_CONFIG_FILES(packaging/normalize.spec packaging/normalize.list)
327AC_CONFIG_FILES(Makefile doc/Makefile doc/fr/Makefile po/Makefile.in
328		src/Makefile nid3lib/Makefile xmms-rva/Makefile test/Makefile)
329AC_OUTPUT
330
331echo
332echo "Configuration:"
333echo "    audiofile library:         $use_audiofile"
334echo "    mpeg audio support:        $use_mad"
335echo "    xmms volume adjust plugin: $use_xmms"
336echo
337