1dnl configure.ac: source for the configure script
2
3dnl copyright by the mpg123 project - free software under the terms of the LGPL 2.1
4dnl see COPYING and AUTHORS files in distribution or http://mpg123.org
5dnl initially written by Nicholas J. Humfrey
6
7dnl Require autoconf version >= 2.57
8AC_PREREQ(2.57)
9
10dnl ############# Initialisation
11AC_INIT([mpg123], [1.25.6], [maintainer@mpg123.org])
12dnl Increment API_VERSION when the API gets changes (new functions).
13
14dnl libmpg123
15API_VERSION=44
16LIB_PATCHLEVEL=5
17
18dnl libout123
19OUTAPI_VERSION=2
20OUTLIB_PATCHLEVEL=1
21
22dnl Since we want to be backwards compatible, both sides get set to API_VERSION.
23LIBMPG123_VERSION=$API_VERSION:$LIB_PATCHLEVEL:$API_VERSION
24LIBOUT123_VERSION=$OUTAPI_VERSION:$OUTLIB_PATCHLEVEL:$OUTAPI_VERSION
25AC_SUBST(LIBMPG123_VERSION)
26AC_SUBST(API_VERSION)
27AC_SUBST(LIBOUT123_VERSION)
28AC_SUBST(OUTAPI_VERSION)
29
30
31AC_CONFIG_SRCDIR(src/mpg123.c)
32AC_CONFIG_AUX_DIR(build)
33AC_CONFIG_SRCDIR(doc)
34AC_CONFIG_MACRO_DIR([m4])
35AC_CANONICAL_HOST
36
37dnl Version 1.7 of automake is recommended
38dnl Not sure what minimal version does not choke on sub directories.
39dnl Testing with 1.14.
40AM_INIT_AUTOMAKE([subdir-objects])
41AC_CONFIG_HEADERS([src/config.h])
42
43
44# You get strange symptoms like jack module build failing because the AC_C_CONST failed to detect the working const support.
45# In that case, the test failed because -Werror, not because no const there...
46# After looking again, there are possibly more tests being obscured by false failures.
47AC_MSG_CHECKING([for -Werror in CFLAGS (It breaks tests)])
48if echo "$CFLAGS" | grep Werror; then
49	AC_MSG_RESULT([yes])
50	AC_MSG_WARN([You have -Werror in CFLAGS. That may break some tests and make this configure bogus.
51If you want paranoid compilation, use --enable-nagging option, which adds -Werror for gcc.
52Also note that you shall not run make distcheck after configuring with --enable-nagging.
53distcheck uses the generated CFLAGS...
54Anyhow, continuing at your own risk.])
55else
56	AC_MSG_RESULT([no])
57fi
58
59buffer=enabled # try to build with buffer by default
60
61dnl ############# Compiler and tools Checks
62
63LT_LDFLAGS=-export-dynamic
64EXEC_LT_LDFLAGS=
65be_static=no
66all_static=no
67lib_static=no
68AC_MSG_CHECKING([if you are up to something totally static with LDFLAGS/CFLAGS])
69for f in $LDFLAGS $CFLAGS
70do
71	case "$f" in
72		-all-static)
73			be_static=yes
74			all_static=yes
75			lib_static=yes
76		;;
77		-static)
78			be_static=yes
79			lib_static=yes
80		;;
81		-static-libgcc)
82			lib_static=yes
83		;;
84	esac
85done
86if test "x$be_static" = xyes; then
87	AC_MSG_RESULT([yes])
88	LT_LDFLAGS=-all-static
89	EXEC_LT_LDFLAGS="$LT_LDFLAGS"
90else
91	AC_MSG_RESULT([no])
92fi
93if test "x$all_static" = xyes; then
94	AC_MSG_WARN( Use -static in LDFLAGS for all-static linking! Your compiler may blow up on that -all-static. )
95fi
96
97AM_PROG_AS
98AC_PROG_CC
99AM_PROG_CC_C_O
100AC_PROG_CPP
101AC_PROG_INSTALL
102AC_CHECK_LIBM
103AC_SUBST(LIBM)
104dnl "Checking for egrep is broken after removal of libltdl stuff... checks use $EGREP, so searching it here."
105AC_PROG_EGREP
106AC_C_CONST
107AC_INLINE
108AC_C_BIGENDIAN
109
110if test "x$lib_static" = xyes; then
111        CC="$CC -static-libgcc"
112        CCLD="$CC"
113	echo "Adding -static-libgcc"
114fi
115
116dnl ############# Use Libtool for dynamic module loading
117
118modules=auto
119OUTPUT_OBJ="module.\$(OBJEXT)"
120AC_ARG_ENABLE(modules,
121[  --enable-modules=[no/yes] dynamically loadable output modules],
122[
123	if test "x$enableval" = xyes
124	then
125		modules=enabled
126	else
127		modules=disabled
128	fi
129],
130[
131	if test "x$be_static" = "xyes"; then
132		modules=disabled
133	else
134		modules=auto
135	fi
136])
137
138dnl We only want shared libraries by default
139AC_DISABLE_STATIC
140AC_ENABLE_SHARED
141
142if test x"$enable_shared" = xno; then
143	modules=disabled
144	LT_LDFLAGS=
145else
146	AC_DEFINE(DYNAMIC_BUILD, 1, [ Define if building with dynamcally linked libmpg123])
147fi
148
149dnl We need the windows header also for checking the module mechanism.
150AC_CHECK_HEADERS([windows.h])
151
152if test x"$modules" = xdisabled
153then
154  echo "Modules disabled, not checking for dynamic loading."
155else
156  have_dl=no
157  # The dlopen() API is either in libc or in libdl.
158  if test x$ac_cv_header_windows_h = xyes; then
159    AC_MSG_CHECKING([if LoadLibrary should be used])
160    AC_LINK_IFELSE([AC_LANG_SOURCE([
161
162#ifdef __CYGWIN__
163#error Cygwin should use dlopen
164#endif
165
166#include <windows.h>
167
168int main() {
169  LoadLibraryW(0);
170  GetProcAddress(0, 0);
171  FreeLibrary(0);
172}
173    ])], [
174    have_dl=yes
175    AC_MSG_RESULT([Using LoadLibrary])
176    ],
177  [AC_MSG_RESULT([no])])
178  else
179    AC_SEARCH_LIBS(dlopen, dl)
180    AC_CHECK_HEADER(dlfcn.h)
181    AC_CHECK_FUNCS(dlopen dlsym dlclose, [ have_dl=yes ])
182  fi
183  if test x"$modules" = xenabled -a x"$have_dl" = xno; then
184    AC_MSG_ERROR([Modules enabled but no runtime loader found! This will not work...])
185  fi
186  if test x"$modules" = xauto; then
187    if test x"$have_dl" = xyes; then
188      modules=enabled
189      echo "We found a runtime loader: Modules enabled."
190    else
191      echo "We did not find a runtime loader: Modules disabled."
192      modules=disabled
193    fi
194  fi
195fi
196
197dnl Configure libtool
198
199AC_LIBTOOL_WIN32_DLL
200AM_PROG_LIBTOOL
201
202if test x"$modules" = xdisabled
203then
204  echo "Modules disabled."
205else
206  # Enable module support in source code
207  AC_DEFINE( USE_MODULES, 1, [Define if modules are enabled] )
208  # Export the module file suffix as LT_MODULE_EXT
209  LT_SYS_MODULE_EXT
210fi
211AM_CONDITIONAL( [HAVE_MODULES], [test "x$modules" = xenabled] )
212
213AC_SUBST(LT_LDFLAGS)
214AC_SUBST(EXEC_LT_LDFLAGS)
215
216dnl ############## Configurable Options
217
218AC_ARG_ENABLE(debug,
219              [  --enable-debug=[no/yes] turn on debugging],
220              [
221                if test "x$enableval" = xyes
222                then
223                  debugging="enabled"
224                else
225                  debugging="disabled"
226                fi
227              ],
228              [ debugging="disabled" ]
229)
230
231AC_ARG_ENABLE(nagging,
232              [  --enable-nagging=[no/yes] turn on GCC's pedantic nagging with error on warnings, does not include --enable-debug anymore ],
233              [
234                if test "x$enableval" = xyes
235                then
236                  nagging="enabled"
237               else
238                  nagging="disabled"
239                fi
240              ],
241              [ nagging="disabled" ]
242)
243
244if test x"$debugging" = xenabled; then
245	AC_DEFINE(DEBUG, 1, [ Define if debugging is enabled. ])
246fi
247
248AC_ARG_ENABLE(gapless,
249              [  --enable-gapless=[no/yes] turn on gapless (enabled per default)],
250              [
251                if test "x$enableval" = xyes
252                then
253                  gapless="enabled"
254                  AC_DEFINE(GAPLESS, 1, [ Define if gapless is enabled. ])
255                else
256                  gapless="disabled"
257                fi
258              ],
259              [
260                gapless="enabled"
261                AC_DEFINE(GAPLESS, 1, [ Define if gapless is enabled. ])
262              ]
263)
264
265AC_ARG_ENABLE(fifo,
266              [  --enable-fifo=[no/yes] FIFO support for control interface (auto-enabled on linux) ],
267              [
268                if test "x$enableval" = xyes
269                then
270                  fifo="enabled"
271                else
272                  fifo="disabled"
273                fi
274              ],
275              [
276                fifo="auto"
277              ]
278)
279
280AC_ARG_ENABLE(ipv6,
281              [  --enable-ipv6=[no/yes] IPv6 support (actually any protocol your libc does with getaddrinfo) ],
282              [
283                if test "x$enableval" = xyes
284                then
285                  ipv6="enabled"
286                else
287                  ipv6="disabled"
288                fi
289              ],
290              [
291                ipv6="auto"
292              ]
293)
294
295AC_ARG_ENABLE(network,
296              [  --enable-network=[no/yes] network support (http streams / webradio) ],
297              [
298                if test "x$enableval" = xyes
299                then
300                  network="enabled"
301                else
302                  network="disabled"
303                fi
304              ],
305              [
306                network="auto"
307              ]
308)
309
310dnl Optional objects list, depends on decoder choice and core feature selection.
311dnl Not just for specific decoders anymore...
312s_fpu=
313DECODER_OBJ=
314DECODER_LOBJ=
315
316dnl Core features that can be disabled to reduce binary size.
317
318id3v2=enabled
319AC_ARG_ENABLE(id3v2,
320              [  --disable-id3v2=[no/yes] no ID3v2 parsing ],
321              [
322                if test "x$enableval" = xno; then
323                  id3v2="disabled"
324                fi
325              ], [])
326
327# id3v2 depends on strings... so check that in between.
328string=enabled
329AC_ARG_ENABLE(string,
330              [  --disable-string=[no/yes] no string API (this will disable ID3v2; main mpg123 won't build anymore) ],
331              [
332                if test "x$enableval" = xno; then
333                  string="disabled"
334                fi
335              ], [])
336
337if test "x$string" = "xdisabled"; then
338  AC_DEFINE(NO_STRING, 1, [ Define to disable string functions. ])
339  id3v2=disabled
340 	AC_MSG_WARN([ID3v2 support disabled because of string API being disabled.])
341else
342  DECODER_OBJ="$DECODER_OBJ stringbuf.\$(OBJEXT)"
343  DECODER_LOBJ="$DECODER_LOBJ stringbuf.lo"
344fi
345
346if test "x$id3v2" = "xdisabled"; then
347  AC_DEFINE(NO_ID3V2, 1, [ Define to disable ID3v2 parsing. ])
348fi
349
350icy=enabled
351AC_ARG_ENABLE(icy,
352              [  --disable-icy=[no/yes] no ICY metainfo parsing/conversion (main mpg123 won't build!) ],
353              [
354                if test "x$enableval" = xno; then
355                  icy="disabled"
356                fi
357              ], [])
358
359if test "x$icy" = "xdisabled"; then
360  AC_DEFINE(NO_ICY, 1, [ Define to disable ICY handling. ])
361else
362  DECODER_OBJ="$DECODER_OBJ icy.\$(OBJEXT) icy2utf8.\$(OBJEXT)"
363  DECODER_LOBJ="$DECODER_LOBJ icy.lo icy2utf8.lo"
364fi
365
366ntom=enabled
367AC_ARG_ENABLE(ntom,
368              [  --disable-ntom=[no/yes] no flexible resampling ],
369              [
370                if test "x$enableval" = xno; then
371                  ntom="disabled"
372                fi
373              ], [])
374
375if test "x$ntom" = "xdisabled"; then
376  AC_DEFINE(NO_NTOM, 1, [ Define to disable ntom resampling. ])
377else
378  DECODER_OBJ="$DECODER_OBJ ntom.\$(OBJEXT)"
379  DECODER_LOBJ="$DECODER_LOBJ ntom.lo"
380fi
381
382downsample=enabled
383AC_ARG_ENABLE(downsample,
384              [  --disable-downsample=[no/yes] no downsampled decoding ],
385              [
386                if test "x$enableval" = xno; then
387                  downsample="disabled"
388                fi
389              ], [])
390
391if test "x$downsample" = "xdisabled"; then
392  AC_DEFINE(NO_DOWNSAMPLE, 1, [ Define to disable downsampled decoding. ])
393fi
394
395feeder=enabled
396AC_ARG_ENABLE(feeder,
397              [  --disable-feeder=[no/yes] no feeder decoding, no buffered readers ],
398              [
399                if test "x$enableval" = xno; then
400                  feeder="disabled"
401                fi
402              ], [])
403
404if test "x$feeder" = "xdisabled"; then
405  AC_DEFINE(NO_FEEDER, 1, [ Define to disable feeder and buffered readers. ])
406fi
407
408messages=enabled
409AC_ARG_ENABLE(messages,
410              [  --disable-messages=[no/yes] no error/warning messages on the console ],
411              [
412                if test "x$enableval" = xno; then
413                  messages="disabled"
414                fi
415              ], [])
416
417if test "x$messages" = "xdisabled"; then
418  AC_DEFINE(NO_WARNING, 1, [ Define to disable warning messages. ])
419  AC_DEFINE(NO_ERRORMSG,   1, [ Define to disable error messages. ])
420  AC_DEFINE(NO_ERETURN, 1, [ Define to disable error messages in combination with a return value (the return is left intact). ])
421fi
422
423newhuff=enabled
424AC_ARG_ENABLE(new-huffman,
425[  --enable-new-huffman=[yes/no] use new huffman decoding scheme by Taihei (faster on modern CPUs at least, so on by default) ],
426[
427  if test "x$enableval" = xno; then
428    newhuff=disabled
429  fi
430]
431, [])
432
433if test "x$newhuff" = "xenabled"; then
434  AC_DEFINE(USE_NEW_HUFFTABLE, 1, [ Define for new Huffman decoding scheme. ])
435fi
436
437integers=fast
438AC_ARG_ENABLE(int-quality,
439[  --enable-int-quality=[yes/no] use rounding instead of fast truncation for integer output, where possible ],
440[
441  if test "x$enableval" = xyes; then
442    integers=quality
443    AC_DEFINE(ACCURATE_ROUNDING,   1, [ Define to use proper rounding. ])
444  fi
445], [])
446
447int16=enabled
448AC_ARG_ENABLE(16bit,
449              [  --disable-16bit=[no/yes] no 16 bit integer output ],
450              [
451                if test "x$enableval" = xno; then
452                  int16="disabled"
453                fi
454              ], [])
455
456int8=enabled
457AC_ARG_ENABLE(8bit,
458              [  --disable-8bit=[no/yes] no 8 bit integer output ],
459              [
460                if test "x$enableval" = xno; then
461                  int8="disabled"
462                fi
463              ], [])
464
465int32=enabled
466AC_ARG_ENABLE(32bit,
467              [  --disable-32bit=[no/yes] no 32 bit integer output (also 24 bit) ],
468              [
469                if test "x$enableval" = xno; then
470                  int32="disabled"
471                fi
472              ], [])
473
474real=enabled
475AC_ARG_ENABLE(real,
476              [  --disable-real=[no/yes] no real (floating point) output ],
477              [
478                if test "x$enableval" = xno; then
479                  real="disabled"
480                fi
481              ], [])
482
483equalizer=enabled
484AC_ARG_ENABLE(equalizer,
485              [  --disable-equalizer=[no/yes] no equalizer support ],
486              [
487                if test "x$enableval" = xno; then
488                  equalizer="disabled"
489                fi
490              ], [])
491
492
493AC_ARG_WITH([cpu], [
494  --with-cpu=generic[[_fpu]]      Use generic processor code with floating point arithmetic
495  --with-cpu=generic_float      Plain alias to generic_fpu now... float output is a normal runtime option!
496  --with-cpu=generic_nofpu      Use generic processor code with fixed point arithmetic (p.ex. ARM)
497  --with-cpu=generic_dither     Use generic processor code with floating point arithmetic and dithering for 1to1 16bit decoding.
498  --with-cpu=i386[[_fpu]]         Use code optimized for i386 processors with floating point arithmetic
499  --with-cpu=i386_nofpu         Use code optimized for i386 processors with fixed point arithmetic
500  --with-cpu=i486         Use code optimized for i486 processors (only usable alone!)
501  --with-cpu=i586         Use code optimized for i586 processors
502  --with-cpu=i586_dither  Use code optimized for i586 processors with dithering (noise shaping), adds 256K to binary size
503  --with-cpu=3dnow         Use code optimized for 3DNow processors
504  --with-cpu=3dnow_vintage Use code optimized for older 3DNow processors (K6 family)
505  --with-cpu=3dnowext      Use code optimized for 3DNowExt processors (K6-3+, Athlon)
506  --with-cpu=3dnowext_alone     Really only 3DNowExt decoder, without 3DNow fallback for flexible rate
507  --with-cpu=3dnow_vintage       Use code optimized for older extended 3DNow processors (like K6-III+)
508  --with-cpu=mmx          Use code optimized for MMX processors
509  --with-cpu=mmx_alone          Really only MMX decoder, without i586 fallback for flexible rate
510  --with-cpu=sse          Use code optimized for SSE processors
511  --with-cpu=sse_vintage  Use code optimized for older SSE processors (plain C DCT36)
512  --with-cpu=sse_alone          Really only SSE decoder, without i586 fallback for flexible rate
513  --with-cpu=avx          Use code optimized for x86-64 with AVX processors
514  --with-cpu=x86          Pack all x86 opts into one binary (excluding i486, including dither)
515  --with-cpu=x86-64       Use code optimized for x86-64 processors (AMD64 and Intel64, including AVX and dithered generic)
516  --with-cpu=altivec      Use code optimized for Altivec processors (PowerPC G4 and G5)
517  --with-cpu=ppc_nofpu    Use code optimized for PowerPC processors with fixed point arithmetic
518  --with-cpu=neon         Use code optimized for ARM NEON SIMD engine (Cortex-A series)
519  --with-cpu=arm_fpu      Pack neon and generic[[_dither]] decoders, for ARM processors with FPU and/or NEON
520  --with-cpu=arm_nofpu    Use code optimized for ARM processors with fixed point arithmetic
521  --with-cpu=neon64       Use code optimized for AArch64 NEON SIMD engine
522  --with-cpu=aarch64      Pack neon64 and generic[[_dither]] decoders, for 64bit ARM processors
523])
524
525use_yasm=auto
526AC_ARG_ENABLE(yasm,
527              [  --enable-yasm=[no/yes] enforce yasm instad of default assembler for some optimizations (AVX, currently) ],
528              [
529                if test "x$enableval" = xyes; then
530                  use_yasm="enabled"
531                else
532                  use_yasm="disabled"
533                fi
534              ], [])
535
536AC_ARG_ENABLE(ieeefloat,
537  [  --enable-ieeefloat=[yes/no] use special hackery relying on IEEE 754 floating point storage format (to accurately round to 16 bit integer at bit more efficiently in generic decoder, enabled by default, disable in case you have a very special computer) ],
538  [
539    if test "x$enableval" = xyes; then
540      ieee=enabled
541    else
542      ieee=disabled
543    fi
544  ], [ ieee=enabled ])
545
546if test "x$ieee" = xenabled; then
547  echo "We assume IEEE754 floating point format."
548  AC_DEFINE(IEEE_FLOAT,   1, [ Define to indicate that float storage follows IEEE754. ])
549fi
550
551sys_cppflags=
552newoldwritesample=disabled
553case $host in
554  aarch64-*linux*|arm64-*linux*|aarch64-*bsd*|arm64-*bsd*|aarch64-apple-darwin*|arm64-apple-darwin*)
555    cpu_type="aarch64"
556  ;;
557  arm*-*-linux*-*eabihf|armv7hl*-*-linux*)
558    cpu_type="arm_fpu"
559  ;;
560  arm*-*-linux*)
561    # check that... perhaps we are better off on arm with kernel math emulation
562    cpu_type="arm_nofpu"
563  ;;
564  armv7*-apple-darwin*)
565    cpu_type="arm_fpu"
566  ;;
567  i386-*-linux*|i386-*-kfreebsd*-gnu)
568    cpu_type="i386_fpu"
569    newoldwritesample=enabled
570  ;;
571  i486-*-linux*|i486-*-kfreebsd*-gnu)
572    cpu_type="i486"
573    newoldwritesample=enabled
574  ;;
575  i586-*-linux*|i586-*-kfreebsd*-gnu)
576    cpu_type="x86"
577    newoldwritesample=enabled
578  ;;
579  i686-*-linux*|i686-*-kfreebsd*-gnu)
580    cpu_type="x86"
581    newoldwritesample=enabled
582  ;;
583  x86_64-*-linux*|x86_64-*-kfreebsd*-gnu)
584    cpu_type="x86-64"
585  ;;
586  *-*-linux*|*-*-kfreebsd*-gnu)
587    cpu_type="generic_fpu"
588  ;;
589  i?86-apple-darwin10*)
590    AC_MSG_CHECKING([if CPU type supports x86-64])
591    case `sysctl -n hw.optional.x86_64` in
592      1)
593        AC_MSG_RESULT([yes])
594        cpu_type="x86-64"
595      ;;
596      *)
597        AC_MSG_RESULT([no])
598        cpu_type="x86"
599        newoldwritesample=enabled
600      ;;
601    esac
602  ;;
603  i?86-apple-darwin*)
604    cpu_type="x86"
605    newoldwritesample=enabled
606  ;;
607  x86_64-apple-darwin*)
608    cpu_type="x86-64"
609  ;;
610  *-apple-darwin*)
611    AC_MSG_CHECKING([if CPU type supports AltiVec])
612    case `machine` in
613      ppc7400 | ppc7450 | ppc970)
614        AC_MSG_RESULT([yes])
615        cpu_type="altivec"
616      ;;
617      *)
618        AC_MSG_RESULT([no])
619        cpu_type="generic_fpu"
620      ;;
621    esac
622  ;;
623  i?86-*-dragonfly* | i?86-*-freebsd* | i?86-*-midnightbsd* | i?86-*-mirbsd* | i?86-*-netbsd* | i?86-*-openbsd* | i?86-*-haiku*)
624    cpu_type="x86"
625    newoldwritesample=enabled
626  ;;
627  x86_64-*-dragonfly* | x86_64-*-freebsd* | x86_64-*-midnightbsd* | x86_64-*-mirbsd* | x86_64-*-netbsd* | x86_64-*-openbsd* | x86_64-*-haiku*)
628    cpu_type="x86-64"
629  ;;
630  *-*-dragonfly* | *-*-freebsd* | *-*-midnightbsd* | *-*-mirbsd* | *-*-netbsd* | *-*-openbsd*)
631    cpu_type="generic_fpu"
632  ;;
633  i386-*-solaris*)
634    cpu_type=x86
635    newoldwritesample=enabled
636  ;;
637  x86_64-*-solaris*)
638    cpu_type=x86-64
639  ;;
640  *-*-solaris*)
641    cpu_type="generic_fpu"
642  ;;
643  # os2-emx = OS/2 with some Unix fun; so p.ex. buffer works.
644  # Till we sorted out the assembler troubles, generic CPU is default.
645  i386-pc-os2-emx)
646    cpu_type=generic_fpu
647    newoldwritesample=enabled
648  ;;
649  x86_64-pc-os2-emx)
650    # We are optimistic hat the future knows OS/2 on x86-64;-)
651    cpu_type=generic_fpu
652  ;;
653  *-pc-os2-emx)
654    cpu_type="generic_fpu"
655  ;;
656  *-dec-osf*)
657    cpu_type="generic_fpu"
658  ;;
659  x86_64-*-cygwin*)
660    cpu_type="x86-64"
661  ;;
662  i686-*-cygwin*)
663    cpu_type="x86"
664    newoldwritesample=enabled
665  ;;
666  i586-*-cygwin*)
667    cpu_type="x86"
668    newoldwritesample=enabled
669  ;;
670  i486-*-cygwin*)
671    cpu_type="i486"
672    newoldwritesample=enabled
673  ;;
674  i386-*-cygwin*)
675    cpu_type="i386"
676    newoldwritesample=enabled
677  ;;
678  *-cygwin*)
679    cpu_type="generic_fpu"
680  ;;
681  i@<:@3-7@:>@86-*-mingw32*)
682    LIBS="$LIBS"
683    buffer=disabled
684    cpu_type="x86"
685    newoldwritesample=enabled
686  ;;
687  x86_64-*-mingw32*)
688    LIBS="$LIBS"
689    buffer=disabled
690    cpu_type="x86-64"
691  ;;
692  i386-*-nto-qnx*)
693    cpu_type="x86"
694    newoldwritesample=enabled
695  ;;
696  *-ibm-aix*)
697    AC_MSG_WARN([AIX system detected. You might want to --disable-largefile when trouble about conflicting types for lseek64 and friends occurs.])
698    # Altivec instead? It is developed for MacOS ...
699    cpu_type=generic_fpu
700    # no struct winsize without _ALL_SOURCE
701    sys_cppflags=-D_ALL_SOURCE
702  ;;
703	i386-*)
704		AC_MSG_WARN([Unknown host operating system])
705		cpu_type="i386"
706		buffer=disabled
707		sys_cppflags=-DGENERIC
708    newoldwritesample=enabled
709	;;
710	i486-*)
711		AC_MSG_WARN([Unknown host operating system])
712		cpu_type="i486"
713		buffer=disabled
714		sys_cppflags=-DGENERIC
715    newoldwritesample=enabled
716	;;
717	i586-*)
718		AC_MSG_WARN([Unknown host operating system])
719		cpu_type="x86"
720		buffer=disabled
721		sys_cppflags=-DGENERIC
722    newoldwritesample=enabled
723	;;
724	i686-*)
725		AC_MSG_WARN([Unknown host operating system])
726		cpu_type="x86"
727		buffer=disabled
728		sys_cppflags=-DGENERIC
729    newoldwritesample=enabled
730	;;
731	x86_64-*)
732		AC_MSG_WARN([Unknown host operating system])
733		cpu_type="x86-64"
734		buffer=disabled
735		sys_cppflags=-DGENERIC
736	;;
737  *)
738  	AC_MSG_WARN([Unknown host operating system])
739    cpu_type="generic_fpu"
740    buffer=disabled
741    sys_cppflags=-DGENERIC
742  ;;
743esac
744
745AC_ARG_ENABLE(buffer,
746  [  --enable-buffer=[yes/no] disable audio buffer code (default uses system whitelist... proper checks later) ],
747  [
748    if test "x$enableval" = xyes
749    then
750      echo "Note: Enabling buffer per request... perhaps it will not build anyway."
751      buffer="enabled"
752    else
753      echo "Note: Disabling buffer per request."
754      buffer="disabled"
755    fi
756  ]
757)
758
759AC_ARG_ENABLE(newoldwritesample,
760[  --enable-newoldwritesample=[no/yes] enable new/old WRITE_SAMPLE macro for non-accurate 16 bit output, faster on certain CPUs (default on on x86-32)],
761[
762	if test "x$enableval" = xyes
763	then
764		newoldwritesample=enabled
765	else
766		newoldwritesample=disabled
767	fi
768])
769
770dnl Did user choose other CPU type ?
771if test "x$with_cpu" != "x"; then
772	cpu_type=$with_cpu
773fi
774
775# Flag for 32 bit synth output or post-processing.
776case "$cpu_type" in
777*_nofpu)
778  synth32=false
779  AC_DEFINE(NO_SYNTH32, 1, [ Define for post-processed 32 bit formats. ])
780;;
781*)
782  synth32=true
783;;
784esac
785
786if test "x$int16" = "xdisabled"; then
787  AC_DEFINE(NO_16BIT, 1, [ Define to disable 16 bit integer output. ])
788else
789  DECODER_OBJ="$DECODER_OBJ synth.\$(OBJEXT)"
790  DECODER_LOBJ="$DECODER_LOBJ synth.lo"
791fi
792
793# 8bit works only through 16bit
794if test "x$int16" = "xdisabled"; then
795  int8=disabled
796fi
797if test "x$int8" = "xdisabled"; then
798  AC_DEFINE(NO_8BIT, 1, [ Define to disable 8 bit integer output. ])
799else
800  DECODER_OBJ="$DECODER_OBJ synth_8bit.\$(OBJEXT)"
801  DECODER_LOBJ="$DECODER_LOBJ synth_8bit.lo"
802fi
803
804if test "x$int32" = "xdisabled"; then
805  AC_DEFINE(NO_32BIT, 1, [ Define to disable 32 bit and 24 bit integer output. ])
806else
807  if $synth32; then
808    s_fpu="$s_fpu synth_s32"
809  fi
810fi
811
812if test "x$real" = "xdisabled"; then
813  AC_DEFINE(NO_REAL, 1, [ Define to disable real output. ])
814else
815  if $synth32; then
816    s_fpu="$s_fpu synth_real"
817  fi
818fi
819
820if test "x$equalizer" = "xdisabled"; then
821  AC_DEFINE(NO_EQUALIZER, 1, [ Define to disable equalizer. ])
822fi
823
824layer1=enabled
825AC_ARG_ENABLE(layer1,
826              [  --disable-layer1=[no/yes] no layer I decoding ],
827              [
828                if test "x$enableval" = xno; then
829                  layer1="disabled"
830                fi
831              ], [])
832
833if test "x$layer1" = "xdisabled"; then
834  AC_DEFINE(NO_LAYER1, 1, [ Define to disable layer I. ])
835else
836  # layer1 needs code in layer2
837  DECODER_OBJ="$DECODER_OBJ layer1.\$(OBJEXT) layer2.\$(OBJEXT)"
838  DECODER_LOBJ="$DECODER_LOBJ layer1.lo layer2.lo"
839fi
840
841layer2=enabled
842AC_ARG_ENABLE(layer2,
843              [  --disable-layer2=[no/yes] no layer II decoding ],
844              [
845                if test "x$enableval" = xno; then
846                  layer2="disabled"
847                fi
848              ], [])
849
850if test "x$layer2" = "xdisabled"; then
851  AC_DEFINE(NO_LAYER2, 1, [ Define to disable layer II. ])
852else
853  # layer1 may have added the objects already
854  if test "x$layer1" = "xdisabled"; then
855    DECODER_OBJ="$DECODER_OBJ layer2.\$(OBJEXT)"
856    DECODER_LOBJ="$DECODER_LOBJ layer2.lo"
857  fi
858fi
859
860layer3=enabled
861AC_ARG_ENABLE(layer3,
862              [  --disable-layer3=[no/yes] no layer III decoding ],
863              [
864                if test "x$enableval" = xno; then
865                  layer3="disabled"
866                fi
867              ], [])
868
869if test "x$layer3" = "xdisabled"; then
870  AC_DEFINE(NO_LAYER3, 1, [ Define to disable layer III. ])
871else
872  DECODER_OBJ="$DECODER_OBJ layer3.\$(OBJEXT)"
873  DECODER_LOBJ="$DECODER_LOBJ layer3.lo"
874fi
875
876AC_ARG_WITH([audio], [
877  --with-audio=<list of modules>  Select a list (or only one) of audio output modules (comma or space separated list).
878])
879AC_ARG_WITH([default-audio], [
880  --with-default-audio=aix            Use AIX as default audio output sub-system
881  --with-default-audio=alib           Use Alib as default audio output sub-system (for HPUX)
882  --with-default-audio=alsa           Use ALSA as default audio output sub-system (libasound)
883  --with-default-audio=tinyalsa       Use ALSA as default audio output sub-system (tinyalsa)
884  --with-default-audio=arts           Use aRts as default audio output sub-system (KDE sound server)
885  --with-default-audio=dummy          Use dummy as default audio (when no sound card is available)
886  --with-default-audio=esd            Use ESoundD as default audio output sub-system
887  --with-default-audio=hp             Use HP as default audio output sub-system
888  --with-default-audio=jack           Use JACK as default low-latency audio server
889  --with-default-audio=coreaudio      Use Mac OS X as default audio output sub-system (CoreAudio)
890  --with-default-audio=mint           Use MinT as default audio output sub-system (Atari)
891  --with-default-audio=nas            Use NAS as default audio output (Network Audio System)
892  --with-default-audio=os2            Use OS2 as default audio output sub-system
893  --with-default-audio=oss            Use OSS as default audio output sub-system (/dev/dsp)
894  --with-default-audio=portaudio      Use PortAudio as default audio output sub-system
895  --with-default-audio=pulse          Use Pulse audio server as default audio output sub-system
896  --with-default-audio=qsa            Use QSA as default audio output sub-system
897  --with-default-audio=sdl            Use SDL as default audio output sub-system (Simple DirectMedia Layer)
898  --with-default-audio=sgi            Use SGI as default audio output sub-system (IRIX)
899  --with-default-audio=sndio          Use OpenBSD's sndio as default audio output sub-system
900  --with-default-audio=sun            Use Sun as default audio output sub-system (/dev/audio)
901  --with-default-audio=win32          Use Win32 audio as default audio output sub-system
902  --with-default-audio=win32_wasapi   Use Win32 wasapi audio as default audio output sub-system
903])
904
905AC_ARG_WITH([optimization], [
906  --with-optimization=0   No Optimization
907  --with-optimization=1   Limited Optimization (-O) (for gcc)
908  --with-optimization=2   Default Optimization (-O2 ...) (for gcc)
909  --with-optimization=3   More Optimize than default (-O3 ...) (for gcc)
910  --with-optimization=4   Optimize yet more (-O4 ...) (for gcc)
911])
912
913AC_ARG_WITH([seektable], [
914  --with-seektable=<size> choose size of seek index table (0 disables it), default 1000
915])
916
917
918dnl ############## Modules
919
920# Dummy audio output module is always supported
921output_modules="dummy"
922
923dnl ############## Assembler, compiler properties
924
925# based on posting from John Dalgliesh <johnd@defyne.org> on ffmpeg (LGPL) mailing list
926# extended to use balign if present
927AC_MSG_CHECKING([if .balign is present])
928echo '.balign 4' > conftest.s
929if $CCAS -c -o conftest.o conftest.s 1>/dev/null 2>&1; then
930
931  AC_MSG_RESULT([yes])
932  AC_DEFINE(ASMALIGN_BALIGN, 1, [ Define if .balign is present. ])
933
934else
935
936AC_MSG_RESULT([no])
937
938# find if .align arg is power-of-two or not
939asmalign_exp="unknown"
940if test x"$asmalign_exp" = xunknown; then
941	AC_MSG_CHECKING([if .align takes 2-exponent])
942	asmalign_exp="no"
943	echo '.align 3' > conftest.s
944	if $CCAS -c -o conftest.o conftest.s 1>/dev/null 2>&1; then
945		asmalign_exp="yes"
946		AC_MSG_RESULT([yes])
947	else
948		AC_MSG_RESULT([no])
949	fi
950	rm -f conftest.o conftest.s
951fi
952if test x"$asmalign_exp" = xyes; then
953	AC_DEFINE(ASMALIGN_EXP, 1, [ Define if .align takes 3 for alignment of 2^3=8 bytes instead of 8. ])
954else
955	AC_DEFINE(ASMALIGN_BYTE, 1, [ Define if .align just takes byte count. ])
956fi
957
958fi
959
960ccalign="unknown"
961if test x"$ccalign" = xunknown; then
962	AC_MSG_CHECKING([__attribute__((aligned(16)))])
963	ccalign="no"
964	echo '__attribute__((aligned(16))) float var;' > conftest.c
965	if $CC -c -o conftest.o conftest.c >/dev/null 2>&1; then
966		ccalign="yes"
967		AC_MSG_RESULT([yes])
968	else
969		AC_MSG_RESULT([no])
970	fi
971	rm -f conftest.o conftest.c
972fi
973
974dnl We apply alignment hints only to cpus that need it.
975dnl See further below for the definition of CCALIGN
976
977avx_support="unknown"
978if test x"$avx_support" = xunknown; then
979	AC_MSG_CHECKING([if assembler supports AVX instructions])
980	avx_support="no"
981	echo '.text' > conftest.s
982	echo 'vaddps %ymm0,%ymm0,%ymm0' >> conftest.s
983	if $CCAS -c -o conftest.o conftest.s 1>/dev/null 2>&1; then
984		avx_support="yes"
985		AC_MSG_RESULT([yes])
986	else
987		AC_MSG_RESULT([no])
988	fi
989	rm -f conftest.o conftest.s
990fi
991
992check_yasm=no
993if test x"$avx_support" = xno || test x"$use_yasm" = xenabled; then
994  check_yasm=yes
995fi
996if test x"$use_yasm" = xdisabled; then
997  check_yasm=no
998fi
999
1000if test x"$check_yasm" = xyes; then
1001	AC_CHECK_PROGS(YASM,[yasm],no)
1002	if test x"$YASM" != xno; then
1003		AC_MSG_CHECKING([if $YASM supports GAS syntax and AVX instructions])
1004		echo '.text' > conftest.s
1005		echo 'vaddps %ymm0,%ymm0,%ymm0' >> conftest.s
1006		if $YASM -pgas -rcpp -o conftest.o conftest.s 1>/dev/null 2>&1; then
1007			avx_support="yes"
1008			YASMFLAGS="-pgas -rgas -mamd64"
1009			AC_MSG_RESULT([yes])
1010		else
1011			AC_MSG_RESULT([no])
1012		fi
1013		rm -f conftest.o conftest.s
1014	else
1015		if test x"$use_yasm" = xenabled; then
1016			AC_MSG_ERROR([Yasm enforced but not found!])
1017		fi
1018	fi
1019else
1020	YASM="no"
1021fi
1022
1023if test "x$cpu_type" = "xavx"; then
1024	if test "x$avx_support" != "xyes"; then
1025		AC_MSG_ERROR([Assembler doesn't understand AVX instructions.])
1026	fi
1027fi
1028
1029AC_SUBST(YASM)
1030AC_SUBST(YASMFLAGS)
1031
1032dnl ############## Really basic headers, needed for other checks.
1033
1034AC_HEADER_STDC
1035dnl Is it too paranoid to specifically check for stdint.h and limits.h?
1036AC_CHECK_HEADERS([stdio.h stdlib.h string.h unistd.h sched.h sys/ioctl.h sys/types.h stdint.h limits.h inttypes.h sys/time.h sys/wait.h sys/resource.h sys/signal.h signal.h sys/select.h dirent.h sys/stat.h])
1037
1038dnl ############## Types
1039
1040dnl Large file support stuff needs cleanup. There are superfluous variables.
1041
1042dnl Detect large file support, enable switches if needed.
1043AC_SYS_LARGEFILE
1044dnl If we do have a switch for large files, rename off_t-aware API calls.
1045dnl Using the file_offset_bits variable here is fine for linux (possibly Solaris),
1046dnl Others... we'll have to see.
1047dnl Note: I started writing this with with multiline replacements.
1048dnl Does not work. Automake insists on putting these into Makefiles where they break things.
1049dnl It is also assumed that a system that does not set file offset bits is not
1050dnl sensitive to largefile changes, i.e. FreeBSD always using 64 bit off_t.
1051if test "x$ac_cv_sys_file_offset_bits" = x || echo "$ac_cv_sys_file_offset_bits" | $GREP  '@<:@^0-9@:>@' > /dev/null; then
1052	dnl if it has non-numeric chars or is empty... ignore...
1053	LFS_LOBJ=
1054	largefile_sensitive=no
1055else
1056	# Add dual-mode wrapper code.
1057	LFS_LOBJ=lfs_wrap.lo
1058	largefile_sensitive=yes
1059fi
1060
1061# Using the lower level macros instead of AC_TYPE_* for compatibility with not freshest autoconf.
1062AC_CHECK_TYPE(size_t, unsigned long)
1063AC_CHECK_TYPE(uintptr_t, unsigned long)
1064AC_CHECK_TYPE(ssize_t, long)
1065AC_CHECK_TYPE(off_t,  long int)
1066AC_CHECK_TYPE(int32_t, int)
1067AC_CHECK_TYPE(int64_t, long long)
1068AC_CHECK_TYPE(uint32_t, unsigned int)
1069AC_CHECK_TYPE(int16_t, short)
1070AC_CHECK_TYPE(uint16_t, unsigned short)
1071AC_CHECK_SIZEOF(size_t,4)
1072AC_CHECK_SIZEOF(ssize_t,4)
1073AC_CHECK_SIZEOF(off_t,4)
1074AC_CHECK_SIZEOF(int32_t)
1075AC_CHECK_SIZEOF(long,4)
1076
1077dnl The native type used for aliases is what off_t maps to without any largefile-
1078dnl enabling switches. So, it's long int if the system is largefile-senstive,
1079dnl but it is actual plain off_t if the system does not have such switches.
1080if test "x$largefile_sensitive" = xyes; then
1081  lfs_alias_type=long
1082  lfs_alias_size=$ac_cv_sizeof_long
1083else
1084  lfs_alias_type=off_t
1085  lfs_alias_size=$ac_cv_sizeof_off_t
1086fi
1087
1088if test "x$lfs_alias_size" = "x"; then
1089  AC_MSG_ERROR([Cannot determine sizeof(lfs_alias_t)?])
1090else
1091  LFS_ALIAS_BITS=`expr "$lfs_alias_size" "*" "8"`
1092  AC_DEFINE_UNQUOTED([lfs_alias_t], $lfs_alias_type,
1093    [Define to the native offset type (long or actually off_t).])
1094  AC_DEFINE_UNQUOTED([LFS_ALIAS_BITS], $LFS_ALIAS_BITS,
1095    [Define this to the size of native offset type in bits, used for LFS alias functions.])
1096fi
1097
1098lfs_alias=enabled
1099AC_ARG_ENABLE(lfs-alias,
1100              [  --disable-lfs-alias disable alias wrappers for largefile bitness (mpg123_seek_32 or mpg123_seek_64 in addition to mpg123_seek, or the other way around; It is a mess, do not play with this!) ],
1101              [
1102                if test "x$enableval" = xno; then
1103                  lfs_alias="disabled"
1104                fi
1105              ],
1106              [
1107                case $host in
1108                *-cygwin*)
1109                  lfs_alias="disabled"
1110                  AC_MSG_NOTICE([lfs-alias disabled for Cygwin, use --enable-lfs-alias explicitly to enable, only if you know what you are doing])
1111                ;;
1112                esac
1113
1114              ])
1115
1116AC_MSG_CHECKING([if we want to enable alias wrappers for largefile])
1117if test "x$lfs_alias" = "xenabled"; then
1118  AC_MSG_RESULT([yes])
1119  LFS_LOBJ="$LFS_LOBJ lfs_alias.lo"
1120else
1121  AC_MSG_RESULT([no])
1122fi
1123
1124# Again, prepend path for non-recursive make.
1125LFS_LOBJ=`for i in $LFS_LOBJ; do printf ' src/libmpg123/%s' $i; done`
1126AC_SUBST(LFS_LOBJ)
1127
1128
1129dnl ############## Function Checks
1130
1131AC_FUNC_MMAP
1132
1133# Check if system supports termios
1134AC_SYS_POSIX_TERMIOS
1135if test "x$ac_cv_sys_posix_termios" = "xyes"; then
1136  AC_DEFINE_UNQUOTED([HAVE_TERMIOS], 1,
1137  [Define this if you have the POSIX termios library])
1138fi
1139
1140AC_CHECK_FUNCS( random )
1141
1142# Check for sched_setscheduler
1143AC_CHECK_FUNCS( sched_setscheduler setuid getuid)
1144
1145# Check for setpriority
1146AC_CHECK_FUNCS( setpriority )
1147
1148AC_CHECK_FUNCS( strerror )
1149
1150AC_CHECK_FUNCS( setlocale nl_langinfo )
1151
1152AC_CHECK_FUNCS( atoll )
1153
1154AC_CHECK_FUNCS( mkfifo, [ have_mkfifo=yes ], [ have_mkfifo=no ] )
1155
1156dnl ############## Header and Library Checks
1157
1158# locale headers
1159AC_CHECK_HEADERS([locale.h langinfo.h])
1160# Headers for network (http) stuff
1161network_type=Unknown
1162AC_CHECK_HEADERS([netdb.h sys/param.h sys/socket.h netinet/in.h arpa/inet.h])
1163if test "x$ac_cv_header_netdb_h" = "xyes"      &&
1164   test "x$ac_cv_header_sys_param_h" = "xyes"  &&
1165   test "x$ac_cv_header_sys_socket_h" = "xyes" &&
1166   test "x$ac_cv_header_netinet_in_h" = "xyes" &&
1167   test "x$ac_cv_header_arpa_inet_h"  = "xyes"; then
1168  have_network=yes
1169  network_type=Posix
1170else
1171  have_network=no
1172fi
1173
1174dnl trying to get that socket lib settled in one line
1175AC_SEARCH_LIBS(gethostbyname, nsl socket network)
1176dnl OK, two lines... Solaris needs -lnsl -lsocket
1177AC_SEARCH_LIBS(socket, socket)
1178
1179AC_CHECK_FUNCS( getaddrinfo, [ have_ipv6=yes ], [ have_ipv6=no ] )
1180
1181APR_CHECK_GETADDRINFO_ADDRCONFIG()
1182
1183# Substitutions for the installable mpg123.h header
1184if test "x$ac_cv_header_stdio_h" = "xyes"; then
1185	INCLUDE_STDIO_H="#include <stdio.h>"
1186else
1187	INCLUDE_STDIO_H="/* #include <stdio.h> is not available on this system */"
1188fi
1189AC_SUBST(INCLUDE_STDIO_H)
1190
1191if test "x$ac_cv_header_stdlib_h" = "xyes"; then
1192	INCLUDE_STDLIB_H="#include <stdlib.h>"
1193else
1194	INCLUDE_STDLIB_H="/* #include <stdlib.h> is not available on this system */"
1195fi
1196AC_SUBST(INCLUDE_STDLIB_H)
1197
1198if test "x$ac_cv_header_sys_types_h" = "xyes"; then
1199	INCLUDE_SYS_TYPE_H="#include <sys/types.h>"
1200else
1201	INCLUDE_SYS_TYPE_H="/* #include <sys/types.h> is not available on this system */"
1202fi
1203AC_SUBST(INCLUDE_SYS_TYPE_H)
1204
1205
1206# Checks for maths libraries.
1207AC_CHECK_LIB([m], [sqrt])
1208AC_CHECK_LIB([mx], [powf])
1209
1210# attempt to make the signal stuff work... also with GENERIC - later
1211#if test x"$ac_cv_header_sys_signal_h" = xyes; then
1212#	AC_CHECK_FUNCS( sigemptyset sigaddset sigprocmask sigaction )
1213#	if test x"$ac_cv_func_sigemptyset" = xyes &&
1214#	   test x"$ac_cv_func_sigaddset" = xyes &&
1215#	   test x"$ac_cv_func_sigprocmask" = xyes &&
1216#	   test x"$ac_cv_func_sigaction" = xyes; then
1217#	AC_DEFINE(
1218#fi
1219
1220dnl ############## Choose compiler flags and CPU
1221
1222# do not assume gcc here, so no flags by default
1223ADD_CFLAGS=""
1224ADD_CPPFLAGS="$sys_cppflags"
1225ADD_LDFLAGS=""
1226LIBS="$LIBS"
1227
1228# Consider moving that stuff.
1229AC_CHECK_HEADER([os2.h], [ADD_CPPFLAGS="$ADD_CPPFLAGS -DOS2"])
1230# On OS/2, we need to link to os2term to make terminal control actually work.
1231AC_CHECK_LIB([os2term], [tcsetattr], [ADD_LDFLAGS="$ADD_LDFLAGS -los2term"])
1232
1233# If debugging is enabled, just enable debugging symbols.
1234# All other stuff enters nagging territory.
1235if test x"$debugging" = xenabled; then
1236	ADD_CFLAGS="-g"
1237fi
1238# gcc specific...
1239if test x"$GCC" = xyes; then
1240	if test x"$nagging" = xenabled; then
1241		ADD_CFLAGS="$ADD_CFLAGS -Wall -Werror -std=c89 -pedantic -DPLAIN_C89"
1242	fi
1243fi
1244
1245dnl Only try the attribute_align_arg mumbo-jumbo on x86, x86-64 warns/errors out on that attribute.
1246dnl ...dunno even what about other architectures.
1247case $host in
1248  i?86-*)
1249    AC_DEFINE(ABI_ALIGN_FUN, 1, [ Define if your architecture wants/needs/can use attribute_align_arg and alignment checks. It is for 32bit x86... ])
1250 ;;
1251esac
1252
1253s_altivec="synth_altivec dct64_altivec"
1254s_i386="dct64_i386"
1255s_i486="$s_i386 synth_i486 dct64_i486"
1256s_i586="$s_i386 synth_i586"
1257s_i586d="$s_i386 synth_i586_dither"
1258s_3dnow="$s_i386 synth_3dnow dct64_3dnow equalizer_3dnow"
1259s_3dnowext="$s_i386 dct64_3dnowext tabinit_mmx synth_3dnowext"
1260s_3dnow_vintage=$s_3dnow
1261s_3dnowext_vintage=$s_3dnowext
1262if test "x$layer3" = "xenabled"; then
1263  s_3dnow_vintage="$s_3dnow_vintage dct36_3dnow"
1264  s_3dnowext_vintage="$s_3dnowext_vintage dct36_3dnowext"
1265fi
1266s_mmx="$s_i386 dct64_mmx tabinit_mmx synth_mmx"
1267s_sse_vintage="$s_i386 tabinit_mmx dct64_sse_float synth_sse_float synth_stereo_sse_float synth_sse_s32 synth_stereo_sse_s32 "
1268s_sse="$s_sse_vintage dct36_sse"
1269s_x86_64="dct36_x86_64 dct64_x86_64_float synth_x86_64_float synth_x86_64_s32 synth_stereo_x86_64_float synth_stereo_x86_64_s32"
1270s_x86_64_mono_synths="synth_x86_64_float synth_x86_64_s32"
1271s_x86_64_avx="dct36_avx dct64_avx_float synth_stereo_avx_float synth_stereo_avx_s32"
1272s_x86multi="getcpuflags"
1273s_x86_64_multi="getcpuflags_x86_64"
1274s_dither="dither"
1275s_neon="dct36_neon dct64_neon_float synth_neon_float synth_neon_s32 synth_stereo_neon_float synth_stereo_neon_s32"
1276s_neon64="dct36_neon64 dct64_neon64_float synth_neon64_float synth_neon64_s32 synth_stereo_neon64_float synth_stereo_neon64_s32"
1277s_arm_multi="getcpuflags_arm check_neon"
1278
1279# choose optimized 16bit decoder for SSE, quality or fast
1280# note: supporting deactivation of output formats for these decoders would need more logic here
1281if test "x$integers" = "xquality"; then
1282  s_sse="$s_sse synth_sse_accurate synth_stereo_sse_accurate"
1283  s_sse_vintage="$s_sse_vintage synth_sse_accurate synth_stereo_sse_accurate"
1284  s_x86_64="$s_x86_64 synth_x86_64_accurate synth_stereo_x86_64_accurate"
1285  s_x86_64_mono_synths="$s_x86_64_mono_synths synth_x86_64_accurate"
1286  s_x86_64_avx="$s_x86_64_avx synth_stereo_avx_accurate"
1287  s_arm="synth_arm_accurate"
1288  s_neon="$s_neon synth_neon_accurate synth_stereo_neon_accurate"
1289  s_neon64="$s_neon64 synth_neon64_accurate synth_stereo_neon64_accurate"
1290else
1291  s_sse="$s_sse dct64_sse synth_sse" # no stereo
1292  s_sse_vintage="$s_sse_vintage dct64_sse synth_sse" # no stereo
1293  s_x86_64="$s_x86_64 synth_x86_64 dct64_x86_64 synth_stereo_x86_64"
1294  s_x86_64_mono_synths="$s_x86_64_mono_synths synth_x86_64"
1295  s_x86_64_avx="$s_x86_64_avx dct64_avx synth_stereo_avx"
1296  s_arm="synth_arm"
1297  s_neon="$s_neon dct64_neon synth_neon synth_stereo_neon"
1298  s_neon64="$s_neon64 dct64_neon64 synth_neon64 synth_stereo_neon64"
1299fi
1300
1301dnl CPU specific compiler flags and sources
1302case $cpu_type in
1303  generic)
1304    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_GENERIC -DREAL_IS_FLOAT"
1305    more_sources="$s_fpu"
1306    ccalign=no
1307  ;;
1308  generic_dither)
1309    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_GENERIC_DITHER -DREAL_IS_FLOAT"
1310    more_sources="$s_fpu $s_dither"
1311    ccalign=no
1312  ;;
1313dnl Not disabling buffer for float mode... check that this is OK now!
1314  generic_fpu | generic_float)
1315    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_GENERIC -DREAL_IS_FLOAT"
1316    more_sources="$s_fpu"
1317    ccalign=no
1318  ;;
1319  generic_nofpu)
1320    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_GENERIC -DREAL_IS_FIXED"
1321    more_sources=
1322    ccalign=no
1323  ;;
1324  ppc_nofpu)
1325    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_GENERIC -DOPT_PPC -DREAL_IS_FIXED"
1326    more_sources=
1327    ccalign=no
1328  ;;
1329  arm_nofpu)
1330    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_ARM -DREAL_IS_FIXED"
1331    more_sources="$s_arm"
1332    ccalign=no
1333  ;;
1334  altivec)
1335    ADD_CFLAGS="$ADD_CFLAGS -maltivec"
1336    ADD_CPPFLAGS="$ADD_CPPFLAGS -DREAL_IS_FLOAT -DOPT_ALTIVEC"
1337    more_sources="$s_altivec $s_fpu"
1338    AC_MSG_CHECKING([if $CC accepts -faltivec])
1339    touch conftest.c
1340    if $CC -faltivec -c -o conftest.o conftest.c >/dev/null 2>&1; then
1341        ADD_CFLAGS="$ADD_CFLAGS -faltivec"
1342        AC_MSG_RESULT([yes])
1343    else
1344        AC_MSG_RESULT([no])
1345    fi
1346    rm -f conftest.o conftest.c
1347  ;;
1348  neon)
1349    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_NEON -DREAL_IS_FLOAT"
1350    more_sources="$s_neon $s_fpu"
1351  ;;
1352  arm_fpu)
1353    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_GENERIC -DOPT_GENERIC_DITHER -DOPT_NEON -DREAL_IS_FLOAT"
1354    more_sources="$s_neon $s_fpu $s_dither $s_arm_multi"
1355  ;;
1356  neon64)
1357    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_NEON64 -DREAL_IS_FLOAT"
1358    more_sources="$s_neon64 $s_fpu"
1359  ;;
1360  aarch64)
1361    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_GENERIC -DOPT_GENERIC_DITHER -DOPT_NEON64 -DREAL_IS_FLOAT"
1362    more_sources="$s_neon64 $s_fpu $s_dither $s_arm_multi"
1363  ;;
1364  i386)
1365    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I386 -DREAL_IS_FLOAT"
1366    more_sources="$s_fpu $s_i386"
1367    ccalign=no
1368  ;;
1369  i386_fpu)
1370    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I386 -DREAL_IS_FLOAT"
1371    more_sources="$s_fpu $s_i386"
1372    ccalign=no
1373  ;;
1374  i386_nofpu)
1375    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I386 -DREAL_IS_FIXED"
1376    more_sources="$s_i386"
1377    ccalign=no
1378  ;;
1379  i486)
1380    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I486 -DREAL_IS_FLOAT"
1381    more_sources="$s_fpu $s_i486"
1382    ccalign=no
1383  ;;
1384  i586)
1385    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I586 -DREAL_IS_FLOAT"
1386    more_sources="$s_fpu $s_i586"
1387  ;;
1388  i586_dither)
1389    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_I586_DITHER -DREAL_IS_FLOAT"
1390    more_sources="$s_fpu $s_i586d $s_dither"
1391  ;;
1392  3dnow)
1393    # legacy 3dnow had the 3dnow paired with i586...
1394    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_I586 -DOPT_3DNOW -DREAL_IS_FLOAT"
1395    more_sources="$s_fpu $s_i586 $s_3dnow $s_x86multi "
1396  ;;
1397  3dnow_vintage)
1398    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_I586 -DOPT_3DNOW_VINTAGE -DREAL_IS_FLOAT"
1399    more_sources="$s_fpu $s_i586 $s_3dnow_vintage $s_x86multi "
1400  ;;
1401  3dnow_alone)
1402    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_3DNOW -DREAL_IS_FLOAT"
1403    more_sources="$s_fpu $s_3dnow"
1404  ;;
1405  3dnowext_alone)
1406    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_3DNOWEXT -DREAL_IS_FLOAT"
1407    more_sources="$s_fpu $s_3dnowext"
1408  ;;
1409  3dnowext_vintage)
1410    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_3DNOW -DOPT_3DNOWEXT_VINTAGE -DREAL_IS_FLOAT"
1411    more_sources="$s_fpu $s_3dnowext_vintage $s_3dnow $s_x86multi"
1412  ;;
1413  3dnowext)
1414    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_3DNOW -DOPT_3DNOWEXT -DREAL_IS_FLOAT"
1415    more_sources="$s_fpu $s_3dnowext $s_3dnow $s_x86multi"
1416  ;;
1417  mmx_alone|mmx)
1418    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MMX -DREAL_IS_FLOAT"
1419    more_sources="$s_fpu $s_mmx"
1420  ;;
1421  sse_alone|sse)
1422    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_SSE -DREAL_IS_FLOAT"
1423    more_sources="$s_fpu $s_sse"
1424  ;;
1425  sse_vintage)
1426    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_SSE_VINTAGE -DREAL_IS_FLOAT"
1427    more_sources="$s_fpu $s_sse_vintage"
1428  ;;
1429  avx)
1430    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_AVX -DREAL_IS_FLOAT"
1431    more_sources="$s_fpu $s_x86_64_avx $s_x86_64_mono_synths"
1432	if test "x$YASM" != "xno"; then
1433		use_yasm_for_avx="yes"
1434	fi
1435  ;;
1436  x86|x86_dither)
1437    # plain C dct36 always there, for vintage/non-vintage
1438    # Selection of non-/vintage sources implies that
1439    # $s_3dnow_vintage contains $s_3dnow,
1440    # $s_sse contains $s_sse_vintage.
1441    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_GENERIC -DOPT_GENERIC_DITHER -DOPT_I386 -DOPT_I586 -DOPT_I586_DITHER -DOPT_MMX -DOPT_3DNOW -DOPT_3DNOW_VINTAGE -DOPT_3DNOWEXT -DOPT_3DNOWEXT_VINTAGE -DOPT_SSE -DOPT_SSE_VINTAGE -DREAL_IS_FLOAT"
1442    more_sources="$s_fpu $s_i386 $s_i586 $s_i586d $s_mmx $s_3dnow_vintage $s_3dnowext_vintage $s_sse $s_x86multi $s_dither"
1443  ;;
1444  x86-64_alone)
1445    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_X86_64 -DREAL_IS_FLOAT"
1446    more_sources="$s_fpu $s_x86_64"
1447  ;;
1448  x86-64|x86-64_all|x86-64_dither)
1449    ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_MULTI -DOPT_X86_64 -DOPT_GENERIC -DOPT_GENERIC_DITHER -DREAL_IS_FLOAT"
1450    more_sources="$s_fpu $s_x86_64 $s_dither $s_x86_64_multi"
1451	if test "x$avx_support" = "xyes"; then
1452		ADD_CPPFLAGS="$ADD_CPPFLAGS -DOPT_AVX"
1453		more_sources="$more_sources $s_x86_64_avx"
1454		if test "x$YASM" != "xno"; then
1455			use_yasm_for_avx="yes"
1456		fi
1457	fi
1458  ;;
1459  *)
1460  	AC_MSG_ERROR([Unknown CPU type '$cpu_type'])
1461  ;;
1462esac
1463
1464# Use yasm instead of the default assembler for AVX sources
1465if test "x$use_yasm_for_avx" = "xyes"; then
1466	case $host_os in
1467		*cygwin*|*mingw*)
1468			YASM_FORMAT="-f win64"
1469		;;
1470		*darwin*)
1471			YASM_FORMAT="-f macho"
1472		;;
1473		*)
1474			YASM_FORMAT="-f elf"
1475		;;
1476	esac
1477	AC_DEFINE(USE_YASM_FOR_AVX, 1, [Define to use yasm for assemble AVX sources.])
1478fi
1479AM_CONDITIONAL( [USE_YASM_FOR_AVX], [test "x$use_yasm_for_avx" = xyes] )
1480AC_SUBST(YASM_FORMAT)
1481
1482# Check if we want feature report function.
1483AC_MSG_CHECKING([if we want feature report function])
1484feature_report=enabled
1485AC_ARG_ENABLE(feature_report,
1486	[  --disable-feature_report Disable feature report function ],
1487	[
1488		if test "x$enableval" = xno; then
1489		AC_MSG_RESULT([no])
1490		feature_report=disabled
1491		else
1492		AC_MSG_RESULT([yes])
1493		fi
1494	],
1495	[AC_MSG_RESULT([yes])])
1496
1497if test "x$feature_report" = xenabled; then
1498	more_sources="$more_sources feature"
1499fi
1500
1501# Return 0 if first arg appears in list of following arguments.
1502# Return 1 otherwise.
1503word_in_list() {
1504  word=$1
1505  shift
1506  # Avoid naming conflict with the outside!
1507  # Is local not POSIX sh?
1508  for given_word in "$@"
1509  do
1510    if test "x$word" = "x$given_word"; then
1511      return 0
1512    fi
1513  done
1514  return 1
1515}
1516
1517for i in $more_sources
1518do
1519  # Make sure every file is only once in the list.
1520  word_in_list "$i.\$(OBJEXT)" $DECODER_OBJ || DECODER_OBJ="$DECODER_OBJ $i.\$(OBJEXT)"
1521  word_in_list "$i.lo" $DECODER_LOBJ || DECODER_LOBJ="$DECODER_LOBJ $i.lo"
1522done
1523
1524# Another preprocessing step: Append prefix for non-recursive make.
1525# Just because $(addprefix ...) is a GNU extension.
1526
1527DECODER_OBJ=`for i in $DECODER_OBJ; do printf ' src/libmpg123/%s' $i; done`
1528DECODER_LOBJ=`for i in $DECODER_LOBJ; do printf ' src/libmpg123/%s' $i; done`
1529
1530AC_SUBST(DECODER_OBJ)
1531AC_SUBST(DECODER_LOBJ)
1532
1533dnl Finally insert the code switch for alignment, above cpu selection having possibly changed the setting.
1534if test x"$ccalign" = xyes; then
1535	AC_DEFINE(CCALIGN, 1, [ Define if __attribute__((aligned(16))) shall be used ])
1536fi
1537
1538
1539dnl ############## Output module choice
1540
1541# The full list of supported modules to check, first come, first serve.
1542check_modules="alsa tinyalsa oss coreaudio sndio sun win32 win32_wasapi os2 esd jack portaudio pulse sdl nas arts openal dummy"
1543# Only check qsa before all else on QNX.
1544# It would mask ALSA otherwise.
1545case $host in
1546  *-nto-qnx*)
1547    check_modules="qsa $check_modules"
1548  ;;
1549esac
1550
1551# The final list.
1552output_modules=
1553
1554check_forced=no
1555check_failed=no
1556if test "x$with_audio" != "x"; then
1557	check_modules="`echo $with_audio|tr , ' '` dummy"
1558	echo "Limiting outputs to build according to your preference: $check_modules"
1559	check_forced=yes
1560fi
1561
1562PKG_PROG_PKG_CONFIG([])
1563
1564# Now go through the modules to check and do the chores.
1565for m in $check_modules
1566do
1567	case "$m" in
1568		dummy)
1569			AC_MSG_CHECKING([if you are too dumbing dumb for the dummy])
1570			AC_MSG_RESULT([no])
1571			output_modules="$output_modules dummy"
1572			HAVE_DUMMY=yes
1573		;;
1574		oss)
1575			AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h machine/soundcard.h])
1576			if test "x${ac_cv_header_sys_soundcard_h}" = "xyes" \
1577				 -o "x${ac_cv_header_linux_soundcard_h}" = "xyes" \
1578				 -o "x${ac_cv_header_machine_soundcard_h}" = "xyes";
1579			then
1580				output_modules="$output_modules oss"
1581				HAVE_OSS="yes"
1582			else
1583				check_failed=yes
1584			fi
1585		;;
1586		tinyalsa)
1587			TINYALSA_LIBS="-ltinyalsa"
1588			# Check for ALSA
1589			AC_CHECK_LIB( [tinyalsa], [pcm_open],
1590				[ AC_CHECK_HEADER( [tinyalsa/asoundlib.h],
1591					[ output_modules="$output_modules tinyalsa" HAVE_TINYALSA="yes"],
1592					[ AC_MSG_WARN([Found TINYALSA library but NOT header files on your system]) ] )
1593				]
1594			)
1595			if test "x$HAVE_TINYALSA" != xyes; then
1596				check_failed=yes
1597			fi
1598		;;
1599		# QSA and ALSA are not distinguishable in these tests, need to block
1600		# each other and play with test order depending on platform.
1601		alsa)
1602			if test "x$HAVE_QSA" = xyes; then
1603				HAVE_ALSA=no
1604			else
1605
1606			ALSA_LIBS="-lasound"
1607			# Check for ALSA
1608			AC_CHECK_LIB( [asound], [snd_pcm_open],
1609				[ AC_CHECK_HEADER( [alsa/asoundlib.h],
1610					[ output_modules="$output_modules alsa" HAVE_ALSA="yes"],
1611					[ AC_MSG_WARN([Found ALSA library but NOT header files on your system]) ] )
1612				]
1613			)
1614			if test "x$HAVE_ALSA" != xyes; then
1615				check_failed=yes
1616			fi
1617
1618			fi # HAVE_QSA
1619		;;
1620		qsa)
1621			if test "x$HAVE_ALSA" = xyes; then
1622				HAVE_QSA=no
1623			else
1624
1625			QSA_LIBS="-lasound"
1626			# Check for QSA
1627			AC_CHECK_LIB( [asound], [snd_pcm_open],
1628				[ AC_CHECK_HEADER( [sys/asoundlib.h],
1629					[ output_modules="$output_modules qsa" HAVE_QSA="yes"],
1630					[ AC_MSG_WARN([Found QSA library but NOT header files on your system]) ] )
1631				]
1632			)
1633			if test "x$HAVE_QSA" != xyes; then
1634				check_failed=yes
1635			fi
1636
1637			fi # HAVE_ALSA
1638		;;
1639		jack)
1640			# JACK module uses semaphores, hence -lpthread.
1641			AC_CHECK_LIB( [pthread], [sem_post],
1642				[ PKG_CHECK_MODULES(JACK, jack,
1643					[
1644						output_modules="$output_modules jack"
1645						HAVE_JACK="yes"
1646						JACK_LIBS="$JACK_LIBS -lpthread"
1647					], [ HAVE_JACK="no" check_failed=yes ] )
1648				],
1649				[ HAVE_JACK=no check_failed=yes ]
1650			)
1651		;;
1652		pulse)
1653			PKG_CHECK_MODULES(PULSE, libpulse-simple, output_modules="$output_modules pulse" HAVE_PULSE="yes", HAVE_PULSE="no" check_failed=yes)
1654		;;
1655		esd)
1656			PKG_CHECK_MODULES(ESD, esound, output_modules="$output_modules esd" HAVE_ESD="yes", HAVE_ESD="no" check_failed=yes)
1657		;;
1658		portaudio)
1659			# Remember: This looks only insane because you chose an insane tab width!
1660			PORTAUDIO_LIBS="-lportaudio"
1661			PORTAUDIO_CFLAGS=
1662			case $host in
1663				*-*-mingw32)
1664					# We tested portaudio with MME
1665					if test "x$HAVE_PORTAUDIO" != "xyes"; then
1666						AC_CHECK_LIB( [portaudio], [Pa_Initialize],
1667							[ AC_CHECK_HEADER( [portaudio.h],
1668								[ output_modules="$output_modules portaudio" HAVE_PORTAUDIO_WINMM="yes" HAVE_PORTAUDIO="yes" ],
1669								[ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] )
1670								PORTAUDIO_LIBS="$PORTAUDIO_LIBS -lwinmm"
1671							],
1672							[ HAVE_PORTAUDIO="no"],
1673							[ -lwinmm ]
1674						)
1675					fi
1676				;;
1677				*)
1678					AC_CHECK_LIB( [portaudio], [Pa_Initialize],
1679						[ AC_CHECK_HEADER( [portaudio.h],
1680							[ output_modules="$output_modules portaudio" HAVE_PORTAUDIO="yes" ],
1681							[ AC_MSG_WARN([Found PortAudio library but NOT header files on your system]) ] )
1682						]
1683					)
1684				;;
1685			esac
1686			if test "x$HAVE_PORTAUDIO" != xyes; then
1687				check_failed=yes
1688			else
1689				# See if we have v19 or v18
1690				AC_CHECK_LIB( [portaudio], [Pa_GetVersion], [:], [AC_DEFINE( [PORTAUDIO18], 1, [Define if portaudio v18 API is wanted.]) ], [$PORTAUDIO_LIBS] )
1691			fi
1692		;;
1693		sdl)
1694			PKG_CHECK_MODULES(SDL, sdl, output_modules="$output_modules sdl" HAVE_SDL="yes", HAVE_SDL="no" check_failed=yes)
1695		;;
1696		nas)
1697			NAS_LIBS=-laudio
1698			AC_CHECK_LIB( [audio], [AuOpenServer],
1699				[ AC_CHECK_HEADER( [audio/audiolib.h],
1700					[ output_modules="$output_modules nas" HAVE_NAS="yes"],
1701					[ AC_MSG_WARN([Found NAS library but NOT header files on your system]) ] )
1702				]
1703			)
1704			if test "x$HAVE_NAS" != xyes; then
1705				check_failed=yes
1706			fi
1707		;;
1708		win32)
1709			# Check for windows ... and win32 audio
1710			# Does not work... instead just check for header
1711			# AC_CHECK_LIB( [winmm], [waveOutOpen] )
1712			WIN32_LIBS=-lwinmm
1713			if test x$ac_cv_header_windows_h = xyes; then
1714				output_modules="$output_modules win32"
1715				HAVE_WIN32=yes
1716			else
1717				HAVE_WIN32=no
1718				check_failed=yes
1719			fi
1720		;;
1721		win32_wasapi)
1722			# Check for windows ... and win32 wasapi audio
1723			# Does not work... instead just check for header
1724			# AC_CHECK_LIB( [avrt], [] )
1725            AC_MSG_CHECKING([if we have wasapi headers])
1726            OLD_LIBS=$LIBS
1727            LIBS="$LIBS -lole32 -lavrt"
1728            AC_LINK_IFELSE([AC_LANG_SOURCE([
1729#define COBJMACROS 1
1730#define _WIN32_WINNT 0x601
1731#include <initguid.h>
1732#include <audioclient.h>
1733#include <mmdeviceapi.h>
1734#include <avrt.h>
1735int main(){
1736  /* UUID Checks */
1737  GUID *IDs[] = {
1738    &CLSID_MMDeviceEnumerator,
1739    &IID_IMMDeviceEnumerator,
1740    &IID_IAudioClient,
1741    &IID_IAudioRenderClient
1742  };
1743  return 0;
1744}
1745    ])], [HAVE_WIN32_WASAPI=yes], [HAVE_WIN32_WASAPI=no])
1746			LIBS=$OLD_LIBS
1747			WIN32_WASAPI_LIBS="-lole32 -lavrt"
1748			AC_MSG_RESULT([$HAVE_WIN32_WASAPI])
1749			if test "x$HAVE_WIN32_WASAPI" = xyes; then
1750				output_modules="$output_modules win32_wasapi"
1751			else
1752				check_failed=yes
1753			fi
1754		;;
1755		sndio)
1756			SNDIO_LIBS=-lsndio
1757			AC_CHECK_LIB([sndio], [sio_open],
1758				[AC_CHECK_HEADERS([sndio.h],
1759					[output_modules="$output_modules sndio" HAVE_SNDIO="yes"])
1760				]
1761			)
1762			if test "x$HAVE_SNDIO" != xyes; then
1763				check_failed=yes
1764			fi
1765		;;
1766		sun)
1767			AC_CHECK_HEADERS([sun/audioio.h sys/audioio.h asm/audioio.h sys/audio.h])
1768			if test "x${ac_cv_header_sun_audioio_h}" = "xyes" \
1769				 -o "x${ac_cv_header_sys_audioio_h}" = "xyes" \
1770				 -o "x${ac_cv_header_asm_audioio_h}" = "xyes";
1771			then
1772				output_modules="$output_modules sun"
1773				HAVE_SUN="yes"
1774			else
1775				check_failed=yes
1776			fi
1777		;;
1778		coreaudio)
1779			COREAUDIO_LIBS="-framework AudioToolbox"
1780			AC_CHECK_HEADERS([AudioUnit/AudioUnit.h AudioToolbox/AudioToolbox.h])
1781			if test "x${ac_cv_header_AudioUnit_AudioUnit_h}" = "xyes" \
1782				 -a "x${ac_cv_header_AudioToolbox_AudioToolbox_h}" = "xyes";
1783			then
1784				OLD_LIBS=$LIBS
1785				LIBS="$LIBS $COREAUDIO_LIBS"
1786    			AC_MSG_CHECKING([if AudioUnit functions are available within AudioToolbox])
1787				AC_TRY_LINK(
1788					[#include <AudioUnit/AudioUnit.h>],
1789					[AudioUnitInitialize(NULL);],
1790					[AC_MSG_RESULT([yes])],
1791					[AC_MSG_RESULT([no])
1792					 COREAUDIO_LIBS="$COREAUDIO_LIBS -framework AudioUnit"]
1793				)
1794				LIBS=$OLD_LIBS
1795				AC_CHECK_HEADERS([CoreServices/CoreServices.h],
1796					[COREAUDIO_LIBS="$COREAUDIO_LIBS -framework CoreServices"]
1797				)
1798				if test x"$modules" = xdisabled; then
1799					AC_MSG_WARN([Disabling buffer because of directly linked CoreAudio! Use the module if you need the buffer.])
1800					buffer=disabled
1801				fi
1802				output_modules="$output_modules coreaudio"
1803				HAVE_COREAUDIO="yes"
1804			else
1805				check_failed=yes
1806			fi
1807		;;
1808		arts)
1809			AC_MSG_CHECKING([for artsc])
1810			if artsc-config > /dev/null 2>&1; then
1811				AC_MSG_RESULT([yes])
1812				output_modules="$output_modules arts"
1813				HAVE_ARTS=yes
1814				ARTS_LIBS=`artsc-config --libs`
1815				ARTS_CFLAGS=`artsc-config --cflags`
1816			else
1817				AC_MSG_RESULT([no])
1818				check_failed=yes
1819			fi
1820		;;
1821		openal)
1822			AC_CHECK_HEADERS([OpenAL/al.h OpenAL/alc.h AL/al.h AL/alc.h al.h alc.h])
1823			if test "x${ac_cv_header_OpenAL_al_h}" = "xyes" \
1824				 -a "x${ac_cv_header_OpenAL_alc_h}" = "xyes";
1825			then #Mac OS X
1826				output_modules="$output_modules openal"
1827				OPENAL_LIBS="-framework OpenAL"
1828				OPENAL_CFLAGS="-DOPENAL_SUBDIR_OPENAL"
1829				HAVE_OPENAL="yes"
1830			elif test "x${ac_cv_header_AL_al_h}" = "xyes" \
1831				 -a "x${ac_cv_header_AL_alc_h}" = "xyes";
1832			then #Linux
1833				output_modules="$output_modules openal"
1834				OPENAL_LIBS="-lopenal"
1835				OPENAL_CFLAGS="-DOPENAL_SUBDIR_AL"
1836				HAVE_OPENAL="yes"
1837			elif test "x${ac_cv_header_al_h}" = "xyes" \
1838				 -a "x${ac_cv_header_alc_h}" = "xyes";
1839			then #Windows?
1840				output_modules="$output_modules openal"
1841				OPENAL_LIBS="-lopenal"
1842				OPENAL_CFLAGS=""
1843				HAVE_OPENAL="yes"
1844			else
1845				check_failed=yes
1846			fi
1847		;;
1848		os2)
1849			OS2_LIBS="-los2me -lmmpm2 -lsocket"
1850			AC_CHECK_HEADERS([os2.h])
1851			# os2me.h depends on os2.h
1852			# Yes, that way of coding it is ugly.
1853			if test "x${ac_cv_header_os2_h}" = xyes
1854			then
1855				# We mimick exactly the way how the header will be used.
1856				# It seems to be picky...
1857				AC_CHECK_HEADERS([os2me.h], [], [], [#define INCL_OS2MM
1858#define INCL_DOS
1859#define INCL_VIO
1860#define INCL_KBD
1861#include <os2.h>
1862#])
1863			fi
1864			if test "x${ac_cv_header_os2_h}" = xyes \
1865			   -a   "x${ac_cv_header_os2me_h}" = xyes
1866			then
1867				output_modules="$output_modules os2"
1868				HAVE_OS2=yes
1869			else
1870				check_failed=yes
1871			fi
1872		;;
1873# from here on only forced tests, untested code
1874		hp)
1875			# What's the deal with that and alib?
1876			UNSUPPORTED_AUDIO=yes
1877			AC_CHECK_HEADER([sys/audio.h], [output_modules="$output_modules hp" HAVE_HP=yes], [check_failed=yes])
1878		;;
1879		alib)
1880			UNSUPPORTED_AUDIO=yes
1881			# ALIB_CFLAGS="-I/opt/audio/include"
1882			ALIB_LIBS=-lAlib
1883			# These headers may not be all about audio but they are used.
1884			AC_CHECK_HEADERS([ Alib.h CUlib.h netdb.h netinet/in.h netinet/tcp.h])
1885			if test "x${ac_cv_header_Alib_h}" = xyes \
1886			   -a   "x${ac_cv_header_CUlib_h}" = xyes \
1887			   -a   "x${ac_cv_header_netdb_h}" = xyes \
1888			   -a   "x${ac_cv_header_netinet_in_h}" = xyes \
1889			   -a   "x${ac_cv_header_netinet_tcp_h}" = xyes
1890			then
1891				output_modules="$output_modules alib"
1892				HAVE_ALIB=yes
1893			else
1894				check_failed=yes
1895			fi
1896		;;
1897		mint)
1898			UNSUPPORTED_AUDIO=yes
1899			AC_CHECK_HEADERS([audios.h], [output_modules="$output_modules mint" HAVE_MINT=yes], [check_failes=yes])
1900		;;
1901		aix)
1902			UNSUPPORTED_AUDIO=yes
1903			AC_CHECK_HEADERS([sys/audio.h], [output_modules="$output_modules aix" HAVE_AIX=yes], [check_failed=yes])
1904		;;
1905		sgi)
1906			UNSUPPORTED_AUDIO=yes
1907			SGI_LIBS=-laudio
1908			AC_CHECK_HEADER([dmedia/audio.h], [output_modules="$output_modules sgi" HAVE_SGI=yes], [check_failed=yes])
1909		;;
1910		*)
1911			AC_MSG_ERROR([Unsupported/-known output '$m' demanded!])
1912		;;
1913	esac
1914done
1915
1916if test "x$check_forced" = xyes -a "x$UNSUPPORTED_AUDIO" = xyes; then
1917	AC_MSG_WARN([You requested bulding of an unsupported audio module. Be prepared for happy hacking and please tell us about your experience!])
1918fi
1919
1920if test "x$check_forced" = xyes -a "x$check_failed" = "xyes"; then
1921	AC_MSG_ERROR([One/some of your requested audio modules failed the test!])
1922fi
1923
1924# When you extend check_modules, you should extend this:
1925#for i in alsa qsa oss coreaudio sndio sun win32 win32_wasapi esd jack portaudio pulse sdl nas aix alib arts hp os2 sgi mint openal dummy
1926#do echo $i; done |
1927#perl -ne 'chomp; $big = uc($_); print <<EOT;
1928#AC_SUBST(${big}_LIBS)
1929#AC_SUBST(${big}_LDFLAGS)
1930#AC_SUBST(${big}_CFLAGS)
1931#AM_CONDITIONAL( [HAVE_$big], [test "x\$HAVE_$big" = xyes] )
1932#EOT
1933#'
1934AC_SUBST(TINYALSA_LIBS)
1935AC_SUBST(TINYALSA_LDFLAGS)
1936AC_SUBST(TINYALSA_CFLAGS)
1937AM_CONDITIONAL( [HAVE_TINYALSA], [test "x$HAVE_TINYALSA" = xyes] )
1938AC_SUBST(ALSA_LIBS)
1939AC_SUBST(ALSA_LDFLAGS)
1940AC_SUBST(ALSA_CFLAGS)
1941AM_CONDITIONAL( [HAVE_ALSA], [test "x$HAVE_ALSA" = xyes] )
1942AC_SUBST(QSA_LIBS)
1943AC_SUBST(QSA_LDFLAGS)
1944AC_SUBST(QSA_CFLAGS)
1945AM_CONDITIONAL( [HAVE_QSA], [test "x$HAVE_QSA" = xyes] )
1946AC_SUBST(OSS_LIBS)
1947AC_SUBST(OSS_LDFLAGS)
1948AC_SUBST(OSS_CFLAGS)
1949AM_CONDITIONAL( [HAVE_OSS], [test "x$HAVE_OSS" = xyes] )
1950AC_SUBST(COREAUDIO_LIBS)
1951AC_SUBST(COREAUDIO_LDFLAGS)
1952AC_SUBST(COREAUDIO_CFLAGS)
1953AM_CONDITIONAL( [HAVE_COREAUDIO], [test "x$HAVE_COREAUDIO" = xyes] )
1954AC_SUBST(SNDIO_LIBS)
1955AC_SUBST(SNDIO_LDFLAGS)
1956AC_SUBST(SNDIO_CFLAGS)
1957AM_CONDITIONAL( [HAVE_SNDIO], [test "x$HAVE_SNDIO" = xyes] )
1958AC_SUBST(SUN_LIBS)
1959AC_SUBST(SUN_LDFLAGS)
1960AC_SUBST(SUN_CFLAGS)
1961AM_CONDITIONAL( [HAVE_SUN], [test "x$HAVE_SUN" = xyes] )
1962AC_SUBST(WIN32_LIBS)
1963AC_SUBST(WIN32_LDFLAGS)
1964AC_SUBST(WIN32_CFLAGS)
1965AM_CONDITIONAL( [HAVE_WIN32], [test "x$HAVE_WIN32" = xyes] )
1966AC_SUBST(WIN32_WASAPI_LIBS)
1967AC_SUBST(WIN32_WASAPI_LDFLAGS)
1968AC_SUBST(WIN32_WASAPI_CFLAGS)
1969AM_CONDITIONAL( [HAVE_WIN32_WASAPI], [test "x$HAVE_WIN32_WASAPI" = xyes] )
1970AC_SUBST(ESD_LIBS)
1971AC_SUBST(ESD_LDFLAGS)
1972AC_SUBST(ESD_CFLAGS)
1973AM_CONDITIONAL( [HAVE_ESD], [test "x$HAVE_ESD" = xyes] )
1974AC_SUBST(JACK_LIBS)
1975AC_SUBST(JACK_LDFLAGS)
1976AC_SUBST(JACK_CFLAGS)
1977AM_CONDITIONAL( [HAVE_JACK], [test "x$HAVE_JACK" = xyes] )
1978AC_SUBST(PORTAUDIO_LIBS)
1979AC_SUBST(PORTAUDIO_LDFLAGS)
1980AC_SUBST(PORTAUDIO_CFLAGS)
1981AM_CONDITIONAL( [HAVE_PORTAUDIO], [test "x$HAVE_PORTAUDIO" = xyes] )
1982AC_SUBST(PULSE_LIBS)
1983AC_SUBST(PULSE_LDFLAGS)
1984AC_SUBST(PULSE_CFLAGS)
1985AM_CONDITIONAL( [HAVE_PULSE], [test "x$HAVE_PULSE" = xyes] )
1986AC_SUBST(SDL_LIBS)
1987AC_SUBST(SDL_LDFLAGS)
1988AC_SUBST(SDL_CFLAGS)
1989AM_CONDITIONAL( [HAVE_SDL], [test "x$HAVE_SDL" = xyes] )
1990AC_SUBST(NAS_LIBS)
1991AC_SUBST(NAS_LDFLAGS)
1992AC_SUBST(NAS_CFLAGS)
1993AM_CONDITIONAL( [HAVE_NAS], [test "x$HAVE_NAS" = xyes] )
1994AC_SUBST(AIX_LIBS)
1995AC_SUBST(AIX_LDFLAGS)
1996AC_SUBST(AIX_CFLAGS)
1997AM_CONDITIONAL( [HAVE_AIX], [test "x$HAVE_AIX" = xyes] )
1998AC_SUBST(ALIB_LIBS)
1999AC_SUBST(ALIB_LDFLAGS)
2000AC_SUBST(ALIB_CFLAGS)
2001AM_CONDITIONAL( [HAVE_ALIB], [test "x$HAVE_ALIB" = xyes] )
2002AC_SUBST(ARTS_LIBS)
2003AC_SUBST(ARTS_LDFLAGS)
2004AC_SUBST(ARTS_CFLAGS)
2005AM_CONDITIONAL( [HAVE_ARTS], [test "x$HAVE_ARTS" = xyes] )
2006AC_SUBST(HP_LIBS)
2007AC_SUBST(HP_LDFLAGS)
2008AC_SUBST(HP_CFLAGS)
2009AM_CONDITIONAL( [HAVE_HP], [test "x$HAVE_HP" = xyes] )
2010AC_SUBST(OS2_LIBS)
2011AC_SUBST(OS2_LDFLAGS)
2012AC_SUBST(OS2_CFLAGS)
2013AM_CONDITIONAL( [HAVE_OS2], [test "x$HAVE_OS2" = xyes] )
2014AC_SUBST(SGI_LIBS)
2015AC_SUBST(SGI_LDFLAGS)
2016AC_SUBST(SGI_CFLAGS)
2017AM_CONDITIONAL( [HAVE_SGI], [test "x$HAVE_SGI" = xyes] )
2018AC_SUBST(MINT_LIBS)
2019AC_SUBST(MINT_LDFLAGS)
2020AC_SUBST(MINT_CFLAGS)
2021AM_CONDITIONAL( [HAVE_MINT], [test "x$HAVE_MINT" = xyes] )
2022AC_SUBST(OPENAL_LIBS)
2023AC_SUBST(OPENAL_LDFLAGS)
2024AC_SUBST(OPENAL_CFLAGS)
2025AM_CONDITIONAL( [HAVE_OPENAL], [test "x$HAVE_OPENAL" = xyes] )
2026AC_SUBST(DUMMY_LIBS)
2027AC_SUBST(DUMMY_LDFLAGS)
2028AC_SUBST(DUMMY_CFLAGS)
2029AM_CONDITIONAL( [HAVE_DUMMY], [test "x$HAVE_DUMMY" = xyes] )
2030# Hackery to get rid of module .la files.
2031AC_SUBST(output_modules)
2032for f in $output_modules
2033do
2034  output_modules_la="$output_modules_la output_$f.la"
2035done
2036AC_SUBST(output_modules_la)
2037
2038# Did user choose default audio subsystem ?
2039if test "x$with_default_audio" != "x"; then
2040	default_output_module=$with_default_audio
2041else
2042	default_output_module=`echo "$output_modules" | $AWK '{ print $1 }'`
2043fi
2044
2045# That's (beginning of) the list for mpg123's internal default.
2046default_output_modules=$default_output_module
2047
2048# Setup the static build.
2049# The conditionals always need to be defined by configure, even if
2050# HAVE_MODULES is FALSE!
2051# Here's a script for that tedious list, perhaps to be outsourced together with the one in #src/output/Makefile.am
2052#for i in dummy tinyalsa alsa qsa coreaudio esd jack nas oss portaudio pulse sdl sndio sun win32 win32_wasapi aix alib arts hp os2 sgi mint openal
2053#do echo $i; done |
2054#perl -ne 'chomp; $big = uc($_); print <<EOT;
2055#AM_CONDITIONAL([BUILD_${big}], [ test "$_" = \$default_output_module ])
2056#EOT
2057#'
2058
2059AM_CONDITIONAL([BUILD_DUMMY], [ test "dummy" = $default_output_module ])
2060AM_CONDITIONAL([BUILD_TINYALSA], [ test "tinyalsa" = $default_output_module ])
2061AM_CONDITIONAL([BUILD_ALSA], [ test "alsa" = $default_output_module ])
2062AM_CONDITIONAL([BUILD_QSA], [ test "qsa" = $default_output_module ])
2063AM_CONDITIONAL([BUILD_COREAUDIO], [ test "coreaudio" = $default_output_module ])
2064AM_CONDITIONAL([BUILD_ESD], [ test "esd" = $default_output_module ])
2065AM_CONDITIONAL([BUILD_JACK], [ test "jack" = $default_output_module ])
2066AM_CONDITIONAL([BUILD_NAS], [ test "nas" = $default_output_module ])
2067AM_CONDITIONAL([BUILD_OSS], [ test "oss" = $default_output_module ])
2068AM_CONDITIONAL([BUILD_PORTAUDIO], [ test "portaudio" = $default_output_module ])
2069AM_CONDITIONAL([BUILD_PULSE], [ test "pulse" = $default_output_module ])
2070AM_CONDITIONAL([BUILD_SDL], [ test "sdl" = $default_output_module ])
2071AM_CONDITIONAL([BUILD_SNDIO], [ test "sndio" = $default_output_module ])
2072AM_CONDITIONAL([BUILD_SUN], [ test "sun" = $default_output_module ])
2073AM_CONDITIONAL([BUILD_WIN32], [ test "win32" = $default_output_module ])
2074AM_CONDITIONAL([BUILD_WIN32_WASAPI], [ test "win32_wasapi" = $default_output_module ])
2075AM_CONDITIONAL([BUILD_AIX], [ test "aix" = $default_output_module ])
2076AM_CONDITIONAL([BUILD_ALIB], [ test "alib" = $default_output_module ])
2077AM_CONDITIONAL([BUILD_ARTS], [ test "arts" = $default_output_module ])
2078AM_CONDITIONAL([BUILD_HP], [ test "hp" = $default_output_module ])
2079AM_CONDITIONAL([BUILD_OS2], [ test "os2" = $default_output_module ])
2080AM_CONDITIONAL([BUILD_SGI], [ test "sgi" = $default_output_module ])
2081AM_CONDITIONAL([BUILD_MINT], [ test "mint" = $default_output_module ])
2082AM_CONDITIONAL([BUILD_OPENAL], [ test "openal" = $default_output_module ])
2083
2084if test "x$modules" = xenabled
2085then
2086
2087  # Now make a comma-separated list again... eliminating the possible duplicate and dummy.
2088  for i in $output_modules
2089  do
2090    if test $i != $default_output_module && test $i != dummy; then
2091      default_output_modules=$default_output_modules,$i
2092    fi
2093  done
2094fi
2095
2096AC_DEFINE_UNQUOTED( DEFAULT_OUTPUT_MODULE, "$default_output_modules", [The default audio output module(s) to use] )
2097
2098dnl ############## Compiler Optimizations
2099
2100CFLAGS="$ADD_CFLAGS $CFLAGS"
2101AM_CONDITIONAL([BUILD_BUFFER], [ test x"$buffer" = xenabled ])
2102if test x"$buffer" = xdisabled; then
2103	ADD_CPPFLAGS="$ADD_CPPFLAGS -DNOXFERMEM"
2104fi
2105if test x"$newoldwritesample" = xenabled; then
2106	ADD_CPPFLAGS="$ADD_CPPFLAGS -DNEWOLD_WRITE_SAMPLE"
2107fi
2108CPPFLAGS="$ADD_CPPFLAGS $CPPFLAGS"
2109LDFLAGS="$ADD_LDFLAGS $LDFLAGS"
2110
2111# None chosen?
2112if test "x$with_optimization" = "x"; then
2113	if test x"$debugging" = xenabled; then
2114		with_optimization="0"
2115	else
2116		# enable (gcc specific) default opts only with gcc
2117		if test "x$GCC" = xyes; then
2118			with_optimization="2"
2119		else
2120			with_optimization="0"
2121		fi
2122	fi
2123fi
2124
2125case $with_optimization in
2126  0)
2127    # No Optimizations
2128    CFLAGS="$CFLAGS"
2129  ;;
2130  1)
2131    CFLAGS="-O $CFLAGS"
2132  ;;
2133  2)
2134    CFLAGS="-O2 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math $CFLAGS"
2135  ;;
2136  3)
2137    CFLAGS="-O3 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math $CFLAGS"
2138  ;;
2139  4)
2140    CFLAGS="-O4 -fomit-frame-pointer -funroll-all-loops -finline-functions -ffast-math $CFLAGS"
2141  ;;
2142  *)
2143  	AC_MSG_ERROR([Unknown optimizations level '$with_optimization'])
2144  ;;
2145esac
2146
2147dnl If using gcc, prevent a bad alignment option from breaking things.
2148dnl Let's default to safe 16-byte alignment for any special x86 or altivec stuff.
2149if test "x$GCC" = xyes && echo "$CFLAGS" | $GREP 'mpreferred-stack-boundary=' > /dev/null; then
2150	case $cpu_type in
2151		x86 | i586* | mmx | sse | 3dnow* | altivec)
2152			AC_MSG_WARN( [ You are trying to mess with stack alignment. I know better. ] )
2153			CFLAGS="$CFLAGS -mpreferred-stack-boundary=4"
2154		;;
2155	esac
2156fi
2157
2158dnl ############## Seektable size
2159
2160if test "x$with_seektable" = "x"; then
2161	seektable=1000
2162else
2163	seektable=$with_seektable
2164fi
2165
2166if test "$seektable" -gt 0; then
2167	AC_DEFINE(FRAME_INDEX, 1, [ Define if frame index should be used. ])
2168fi
2169# Define that always... also without frame index enabled.
2170AC_DEFINE_UNQUOTED(INDEX_SIZE, $seektable, [size of the frame index seek table])
2171
2172dnl ############## Win32 function checks
2173# Check if we want Unicode for Win32. Cygwin does not need _wopen
2174if test x$ac_cv_header_windows_h = xyes && test "x$host_os" != "xcygwin"; then
2175  win32_specific_codes=enabled
2176else
2177  win32_specific_codes=disabled
2178fi
2179win32_unicode=unneeded
2180win32_sockets=disabled
2181win32_sockets_working=no
2182win32_wide_working=no
2183win32_winver_bump=no
2184
2185dnl We do not support non-unicode Windows.
2186if test "x$win32_specific_codes" = xenabled; then
2187#### Check for Wide functions
2188  AC_CHECK_FUNC([_wopen], [win32_unicode=enabled],[win32_unicode=disabled])
2189  AC_MSG_CHECKING([if we want Unicode File Open for Win32])
2190  if test "x$win32_unicode" = xenabled; then
2191    dnl We need to include the header for PathCombineW checking as
2192    dnl the actual symbol has a very funny name.
2193    oldlibs=$LIBS
2194    LIBS="$LIBS -lshlwapi"
2195    AC_MSG_RESULT([yes])
2196    AC_MSG_CHECKING([if Unicode functions working])
2197    AC_LINK_IFELSE([AC_LANG_SOURCE([
2198      #include <windows.h>
2199      #include <shlwapi.h>
2200      #include <stdlib.h>
2201      int main()
2202      {
2203        MultiByteToWideChar (0, 0, NULL, 0, NULL, 0);
2204        WideCharToMultiByte (0, 0, NULL, 0, NULL, 0, NULL, NULL);
2205        PathCombineW(0,0,0);
2206        return 0;
2207      }
2208    ])], [win32_wide_working=yes], [win32_winver_bump=yes])
2209    if test "x$win32_wide_working" = xno; then
2210      AC_LINK_IFELSE([AC_LANG_SOURCE([
2211        #define WINVER 0x501
2212        #define _WIN32_WINNT 0x501
2213        #include <windows.h>
2214        #include <shlwapi.h>
2215        #include <stdlib.h>
2216        int main()
2217        {
2218          MultiByteToWideChar (0, 0, NULL, 0, NULL, 0);
2219          WideCharToMultiByte (0, 0, NULL, 0, NULL, 0, NULL, NULL);
2220          PathCombineW(0,0,0);
2221          return 0;
2222        }
2223      ])], [win32_wide_working=yes], [AC_MSG_RESULT([no])])
2224    fi
2225    if test "x$win32_wide_working" = xyes; then
2226      AC_MSG_RESULT([yes])
2227      AC_DEFINE([WANT_WIN32_UNICODE], [1], [ Define to use Unicode for Windows ])
2228    else
2229      LIBS=$oldlibs
2230      AC_MSG_ERROR([Unicode support for Win32 not working])
2231    fi
2232  else
2233    AC_MSG_ERROR([Unicode File Open for Win32 not available])
2234  fi
2235
2236#### Check for Network functions
2237  AC_CHECK_HEADERS([ws2tcpip.h], [win32_sockets=enabled], [AC_MSG_WARN([Please update your headers to support winsock 2.2.])])
2238  AC_MSG_CHECKING([if we want Win32 sockets])
2239  if test "x$win32_sockets" = "xenabled" && test "x$network" != "xdisabled"; then
2240  AC_MSG_RESULT([yes])
2241  AC_MSG_CHECKING([if winsock2 API is available])
2242    wsoldlibs="$LIBS"
2243    LIBS="$LIBS -lws2_32"
2244    AC_LINK_IFELSE([AC_LANG_SOURCE([
2245      #include <winsock2.h>
2246      #include <ws2tcpip.h>
2247      #include <stdlib.h>
2248      int main()
2249      {
2250        getaddrinfo(NULL, NULL, NULL, NULL);
2251        freeaddrinfo(NULL);
2252        return 0;
2253      }
2254    ])], [win32_sockets_working=yes], [win32_winver_bump=yes])
2255    if test "x$win32_sockets_working" = "xno"; then
2256      AC_MSG_CHECKING([deeper if winsock2 API is available])
2257      AC_LINK_IFELSE([AC_LANG_SOURCE([
2258        #define WINVER 0x501
2259        #define _WIN32_WINNT 0x501
2260        #include <winsock2.h>
2261        #include <ws2tcpip.h>
2262        #include <stdlib.h>
2263        int main()
2264        {
2265          getaddrinfo(NULL, NULL, NULL, NULL);
2266          freeaddrinfo(NULL);
2267          return 0;
2268        }
2269      ])], [win32_sockets_working=yes], [AC_MSG_RESULT([no])])
2270    fi
2271    if test "x$win32_sockets_working" = "xyes"; then
2272      AC_MSG_RESULT([yes])
2273      AC_DEFINE([WANT_WIN32_SOCKETS], [1], [ Define to use Win32 sockets ])
2274      network_type=Winsock2
2275      have_network=yes
2276      have_ipv6=yes
2277    else
2278      LIBS="$wsoldlibs"
2279      AC_MSG_WARN([Please update your headers to support winsock 2.2.])
2280    fi
2281  else
2282    AC_MSG_RESULT([no])
2283  fi
2284
2285#### Check for Win32 Named Pipe functions
2286win32_fifo_working=no
2287if test x$win32_specific_codes = xenabled; then
2288  AC_MSG_CHECKING([if we have Named Pipes])
2289  if test "x$fifo" != "xdisabled"; then
2290    AC_LINK_IFELSE([AC_LANG_SOURCE([
2291    #include <windows.h>
2292      int main(){
2293        CreateNamedPipeA(NULL,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL);
2294        CreateNamedPipeW(NULL,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL);
2295        return 0;
2296      }])],[win32_fifo_working=yes],[win32_winver_bump=yes])
2297    if test "x$win32_fifo_working" != "xyes"; then
2298    AC_LINK_IFELSE([AC_LANG_SOURCE([
2299    #define WINVER 0x501
2300    #define _WIN32_WINNT 0x501
2301    #include <windows.h>
2302      int main(){
2303        CreateNamedPipeA(NULL,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL);
2304        CreateNamedPipeW(NULL,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,1,255,255,0,NULL);
2305        return 0;
2306      }])],[win32_fifo_working=yes],[win32_fifo_working=no])
2307    fi
2308  fi
2309  have_mkfifo=$win32_fifo_working
2310  if test "x$win32_fifo_working" = "xyes"; then
2311    AC_MSG_RESULT([yes])
2312    AC_DEFINE([WANT_WIN32_FIFO], [1], [ Define to use Win32 named pipes ])
2313  else
2314    AC_MSG_RESULT([no])
2315  fi
2316fi
2317
2318#### WINVER Bump
2319if test x$win32_specific_codes = xenabled; then
2320  AC_MSG_CHECKING([if WINVER and _WIN32_WINNT needs version bumps])
2321  if test "x$win32_winver_bump" = "xyes"; then
2322    AC_MSG_RESULT([yes])
2323    AC_DEFINE([WINVER], [0x0501], [ WinXP and above for ipv6 ])
2324    AC_DEFINE([_WIN32_WINNT], [0x0501], [ WinXP and above for ipv6 ])
2325    # getaddrinfo and freeaddrinfo are available for Win2K and above
2326    # Bug: MinGW.org w32api ws2tcpip.h incorrectly wants (_WIN32_WINNT >= 0x0501) for getaddrinfo and freeaddrinfo
2327    # MultiByteToWideChar and WideCharToMultiByte are available for Win2K and above
2328  else
2329    AC_MSG_RESULT([no])
2330  fi
2331fi
2332
2333fi #END OF WIN32 CHECKS
2334
2335#### Check mingw.org for EOVERFLOW
2336AC_MSG_CHECKING([if we have EOVERFLOW macro])
2337AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2338#include <errno.h>
2339int i = (EOVERFLOW) + 0;
2340])],[eoverflow_present=yes],[eoverflow_present=no])
2341AC_MSG_RESULT([$eoverflow_present])
2342AS_IF([test "x$eoverflow_present" = "xyes"],[],[AC_DEFINE([EOVERFLOW],[EFBIG],[Use EFBIG as substitude for EOVERFLOW, mingw.org may lack the latter])])
2343
2344#### Use Win32 support codes
2345AM_CONDITIONAL([WIN32_CODES], [ test "x$win32_specific_codes" = xenabled ])
2346
2347if test x"$network" = xauto; then
2348	if test x"$have_network" = xyes; then
2349		network=enabled
2350	else
2351		network=disabled
2352	fi
2353fi
2354if test x"$ipv6" = xauto; then
2355	if test x"$have_ipv6" = xyes; then
2356		ipv6=enabled
2357	else
2358		ipv6=disabled
2359	fi
2360fi
2361
2362dnl ############## FIFO enable
2363
2364if test x"$fifo" = xauto; then
2365	if test x"$have_mkfifo" = xyes; then
2366		fifo=enabled
2367	else
2368		fifo=disabled
2369	fi
2370fi
2371
2372if test x"$fifo" = xenabled; then
2373	AC_DEFINE(FIFO, 1, [ Define if FIFO support is enabled. ])
2374	if test x"$have_mkfifo" = xno; then
2375		AC_MSG_WARN( [ You forced FIFO code while I think there is no mkfifo() available! ] )
2376	fi
2377fi
2378
2379dnl ############## Network enable
2380if test x"$network" = xenabled; then
2381	AC_DEFINE(NETWORK, 1, [ Define if network support is enabled. ])
2382	if test x"$have_network" = xno; then
2383		AC_MSG_WARN( [ You forced network code while I think there is support missing! ] )
2384	fi
2385fi
2386
2387if test x"$ipv6" = xenabled; then
2388	AC_DEFINE(IPV6, 1, [ Define if IPV6 support is enabled. ])
2389	if test x"$have_ipv6" = xno; then
2390		AC_MSG_WARN( [ You forced IPv6 code while I think there is no getaddrinfo() available! ] )
2391	fi
2392fi
2393
2394dnl ############## Final Output
2395
2396AC_CONFIG_FILES([
2397	Makefile
2398	libmpg123.pc
2399	libout123.pc
2400	mpg123.spec
2401	src/libmpg123/mpg123.h
2402	src/libout123/out123.h
2403])
2404
2405AC_OUTPUT
2406
2407
2408
2409dnl ############## Display Message
2410
2411echo "
2412  $PACKAGE_NAME $PACKAGE_VERSION
2413
2414  Install path ............ $prefix
2415  CPU Optimization ........ $cpu_type
2416  Compiler Optimization ... $with_optimization
2417  Gapless Support ......... $gapless
2418  Debugging ............... $debugging
2419  Seek table size ......... $seektable
2420  FIFO support ............ $fifo
2421  Buffer .................. $buffer
2422  Network (http streams) .. $network
2423  Network Sockets ......... $network_type
2424  IPv6 (getaddrinfo) ...... $ipv6"
2425if test x"$LARGEFILE_BITS" = x; then
2426  echo "  File offsets ............ default"
2427else
2428  echo "  File offsets ............ $LARGEFILE_BITS"
2429  echo "    The lib will (try to) support default offset size, too."
2430fi
2431echo "  LFS alias symbols ....... $lfs_alias ($LFS_ALIAS_BITS)"
2432echo "  LFS alias type .......... $lfs_alias_type"
2433if test x"$use_yasm_for_avx" = xyes; then
2434  echo "  Use yasm (for AVX only) . enabled"
2435else
2436  echo "  Use yasm (for AVX only) . disabled"
2437fi
2438
2439echo "
2440  Core libmpg123 features:
2441  Layer I ................. $layer1
2442  Layer II ................ $layer2
2443  Layer III ............... $layer3
2444  NtoM resampling ......... $ntom
2445  downsampled decoding .... $downsample
2446  Feeder/buffered input ... $feeder
2447  ID3v2 parsing ........... $id3v2
2448  String API .............. $string
2449  ICY parsing/conversion .. $icy
2450  Error/warning messages .. $messages
2451  Win32 Unicode File Open.. $win32_unicode
2452  Feature Report Function.. $feature_report
2453  Output formats (nofpu will disable all but 16 or 8 bit!):
2454  8 bit integer ........... $int8
2455  16 bit integer .......... $int16
2456  32/24 bit integer ....... $int32
2457  real (32 bit float) ..... $real
2458  Equalizer ............... $equalizer
2459  Optimization detail:
2460  Integer conversion ...... $integers
2461  IEEE 754 hackery ........ $ieee
2462  New/old WRITE_SAMPLE .... $newoldwritesample
2463  new Huffman scheme ...... $newhuff
2464
2465Note: Disabling core features is not commonly done and some combinations might not build/work. If you encounter such a case, help yourself (and provide a patch) or just poke the maintainers."
2466# just an empty line
2467echo
2468
2469echo "  Modules ................. $modules"
2470echo "  Checked audio modules ... $check_modules
2471  Detected audio support ..$output_modules
2472  Default output module ... $default_output_module
2473"
2474if test x"$modules" = xdisabled; then
2475echo "The _single_ active output module is being statically linked in.
2476"
2477fi
2478if test x"$with_optimization" = x0; then
2479	echo "No optimization flags chosen, make sure you have something basic in your CFLAGS at least...
2480"
2481fi
2482
2483if test x"$cpu_type" = xi486; then
2484  echo "WARNING: You selected the i486 decoder. This is not recommened for regular use."
2485  echo "It was designed for actual i486 CPUs a long time ago. Generic C code is likely"
2486  echo "to perform better nowadays. Also, the decoder misses features like volume"
2487  echo "scaling and has clipping issues. Continue if you are into software archeology"
2488  echo "only."
2489fi
2490
2491echo
2492echo "  CPPFLAGS='$CPPFLAGS'"
2493echo "  CFLAGS='$CFLAGS'"
2494echo "  LIBS='$LIBS'"
2495echo
2496echo "Next type 'make' and then 'make install'."
2497