configure.ac 7.36 KB
Newer Older
Michel Lespinasse's avatar
Michel Lespinasse committed
1
dnl Process this file with autoconf to produce a configure script.
Michel Lespinasse's avatar
Michel Lespinasse committed
2
AC_PREREQ(2.54)
3 4
AC_INIT
AC_CONFIG_SRCDIR([src/a52dec.c])
5 6 7
AC_CONFIG_AUX_DIR(.auto)
AC_CONFIG_FILES([Makefile liba52/Makefile include/Makefile test/Makefile
    doc/Makefile src/Makefile libao/Makefile vc++/Makefile liba52/liba52.pc])
Michel Lespinasse's avatar
Michel Lespinasse committed
8
AM_INIT_AUTOMAKE([a52dec],[0.7.5-cvs])
Michel Lespinasse's avatar
Michel Lespinasse committed
9
AC_CONFIG_HEADERS([include/config.h])
Michel Lespinasse's avatar
Michel Lespinasse committed
10 11 12 13 14 15 16
AM_MAINTAINER_MODE
AC_CANONICAL_HOST

dnl Checks for compiler
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL

17 18 19 20
dnl Checks for headers. We do this before the CC-specific section because
dnl autoconf generates tests for generic headers before the first header test.
AC_CHECK_HEADERS([sys/time.h time.h sys/timeb.h io.h])

21 22
dnl CC-specific flags
AC_SUBST([OPT_CFLAGS])
23
AC_SUBST([ARCH_OPT_CFLAGS])
Michel Lespinasse's avatar
Michel Lespinasse committed
24 25
if test x"$GCC" = x"yes"; then

Michel Lespinasse's avatar
Michel Lespinasse committed
26 27 28 29
    dnl GCC-specific flags

    dnl -Wall
    dnl -Werror moved to the end to not disturb the configure script
30
    TRY_CFLAGS="$OPT_CFLAGS -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
31
    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
Michel Lespinasse's avatar
Michel Lespinasse committed
32 33 34

    dnl -O3
    changequote(<<,>>)
35
    TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"|sed "s/-O[0-9]*//g"`
Michel Lespinasse's avatar
Michel Lespinasse committed
36
    changequote([,])
37
    TRY_CFLAGS="$TRY_CFLAGS -O3"
38
    AC_TRY_CFLAGS([$TRY_CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"; CFLAGS=""])
Michel Lespinasse's avatar
Michel Lespinasse committed
39

40 41 42 43 44 45 46
    AC_ARG_ENABLE([debug],
	[  --enable-debug          debug mode configuration])
    if test x"$enable_debug" = x"yes"; then
	AC_DEFINE([DEBUG],,[debug mode configuration])
    else
	dnl -fomit-frame-pointer
	TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer"
47
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
48
    fi
Michel Lespinasse's avatar
Michel Lespinasse committed
49

50 51 52 53
    dnl -fno-common
    TRY_CFLAGS="$OPT_CFLAGS -fno-common"
    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])

Michel Lespinasse's avatar
Michel Lespinasse committed
54
    dnl arch-specific flags
55
    case "$host" in
56 57
    i?86-* | k?-* | x86_64-* | amd64-*)
	AC_DEFINE([ARCH_X86],,[x86 architecture])
58
	case "$host" in
59 60 61 62 63
	i386-*) TRY_CFLAGS="$OPT_CFLAGS -mtune=i386";;
	i486-*) TRY_CFLAGS="$OPT_CFLAGS -mtune=i486";;
	i586-*) TRY_CFLAGS="$OPT_CFLAGS -mtune=pentium";;
	i686-*) TRY_CFLAGS="$OPT_CFLAGS -mtune=pentiumpro";;
	k6-*)   TRY_CFLAGS="$OPT_CFLAGS -mtune=k6";;
Michel Lespinasse's avatar
Michel Lespinasse committed
64
	esac
65
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    ppc-* | powerpc-*)
	have_altivec=no
	for TRY_CFLAGS in "-mpim-altivec -force_cpusubtype_ALL" -faltivec -maltivec -fvec; do
	    AC_TRY_CFLAGS([$OPT_CFLAGS $TRY_CFLAGS $CFLAGS],
		[save_CFLAGS="$CFLAGS"
		 CFLAGS="$OPT_CFLAGS $TRY_CFLAGS $CFLAGS"
		 AC_MSG_CHECKING([if <altivec.h> is needed])
		 AC_TRY_COMPILE([],
		    [typedef vector int t;
		     vec_ld(0, (unsigned char *)0);],
		    [have_altivec=yes; AC_MSG_RESULT(no)],
		    [AC_TRY_COMPILE([#include <altivec.h>],
			[typedef vector int t; vec_ld(0, (unsigned char *)0);],
			[AC_DEFINE([HAVE_ALTIVEC_H],,
			    [Define to 1 if you have the <altivec.h> header.])
			 have_altivec=yes; AC_MSG_RESULT(yes)],
			[AC_MSG_RESULT(unsupported)])])
		 CFLAGS="$save_CFLAGS"])
	    if test "$have_altivec" = "yes"; then
		ARCH_OPT_CFLAGS="$TRY_CFLAGS"
		AC_DEFINE([ARCH_PPC],,[ppc architecture])
		break
	    fi
	done;;
90
    sparc-* | sparc64-*)
91
	AC_DEFINE([ARCH_SPARC],,[sparc architecture])
92
	TRY_CFLAGS="$OPT_CFLAGS -mtune=ultrasparc"
93
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
94 95
    alpha*)
	AC_DEFINE([ARCH_ALPHA],,[alpha architecture]);;
Michel Lespinasse's avatar
Michel Lespinasse committed
96
    esac
Michel Lespinasse's avatar
Michel Lespinasse committed
97
elif test x"$CC" = x"tendracc"; then
98
    dnl TenDRA portability checking compiler
99
    TENDRA=yes
100
    OPT_CFLAGS="-Xp -Yansi -f`pwd`/include/tendra.h -DELIDE_CODE"
Michel Lespinasse's avatar
Michel Lespinasse committed
101 102 103
    enable_mlib=no
    enable_oss=no
    enable_solaris_audio=no
104 105
elif test x"$CC" = x"icc" -a x"`$CC -V 2>&1 | grep Intel`" != x""; then
    dnl Intel C++ compiler
106
    OPT_CFLAGS="-g -O3 -unroll -ip"; CFLAGS=""
Michel Lespinasse's avatar
Michel Lespinasse committed
107 108
else
    dnl non-gcc flags - we probably need exact configuration triplets here.
109
    case "$host" in
Michel Lespinasse's avatar
Michel Lespinasse committed
110
    sparc-sun-solaris*)
111
	TRY_CFLAGS="$OPT_CFLAGS -xCC -fast -xO5"
112
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
Michel Lespinasse's avatar
Michel Lespinasse committed
113 114 115 116 117
    esac
fi

dnl Checks for libtool - this must be done after we set cflags
AC_LIBTOOL_WIN32_DLL
118
AC_PROG_LIBTOOL
Michel Lespinasse's avatar
Michel Lespinasse committed
119 120 121 122 123

dnl Checks for libraries.

dnl Checks for header files.
INCLUDES='-I$(top_srcdir)/include -I$(top_builddir)/include'
124
AC_SUBST([INCLUDES])
125
AC_HEADER_TIME
126 127 128
AC_CHECK_TYPES([struct timeval], [], [],
    [#include <sys/time.h>
    #include <time.h>])
129
AC_CHECK_GENERATE_INTTYPES([include])
Michel Lespinasse's avatar
Michel Lespinasse committed
130 131 132

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
133
AC_C_ALWAYS_INLINE
134
AC_C_RESTRICT
135
AC_C_BUILTIN_EXPECT
Michel Lespinasse's avatar
Michel Lespinasse committed
136
AC_C_BIGENDIAN
137 138 139
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_SYS_LARGEFILE
Michel Lespinasse's avatar
Michel Lespinasse committed
140 141

dnl Checks for library functions.
142
AC_CHECK_FUNCS([memalign gettimeofday ftime])
Michel Lespinasse's avatar
Michel Lespinasse committed
143

144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
AC_SUBST([LIBA52_CFLAGS])
AC_SUBST([LIBA52_LIBS])

dnl avoid -fPIC when possible
AC_LIBTOOL_NON_PIC([LIBA52_CFLAGS="$LIBA52_CFLAGS -prefer-non-pic"])

AC_ARG_ENABLE([fixed],
    [  --enable-fixed          use fixed-point (integer-based) arithmetic])
AC_ARG_ENABLE([double],
    [  --enable-double         use double-precision samples])
AC_ARG_ENABLE([djbfft],
    [  --enable-djbfft         make a version using djbfft])

if test x"$enable_fixed" = x"yes"; then
    AC_DEFINE([LIBA52_FIXED],,[use fixed-point arithmetic])
elif test x"$enable_double" = x"yes"; then
    AC_DEFINE([LIBA52_DOUBLE],,[a52 sample precision])
fi
if test x"$enable_djbfft" = x"yes"; then
    AC_DEFINE([LIBA52_DJBFFT],,[liba52 djbfft support])
    LIBA52_LIBS="$LIBA52_LIBS -ldjbfft"
fi

AC_SUBST([LIBAO_LIBS])

dnl check for oss
AC_ARG_ENABLE([oss],
    [  --disable-oss           make a version not using oss])
if test x"$enable_oss" != x"no"; then
    case "$host" in
    *-linux*|*-openbsd*|*-freebsd*|*-netbsd*|*-bsdi*)
        AC_DEFINE([LIBAO_OSS],,[libao OSS support])
        AC_CHECK_LIB([ossaudio],[_oss_ioctl],
            [LIBAO_LIBS="$LIBAO_LIBS -lossaudio"]);;
    esac
fi

dnl check for solaris
AC_ARG_ENABLE([solaris-audio],
    [  --disable-solaris-audio make a version not using solaris audio])
if test x"$enable_solaris_audio" != x"no"; then
    case "$host" in
    *-sun-solaris*)
        AC_DEFINE([LIBAO_SOLARIS],,[libao solaris support]);;
    esac
fi

dnl check for al
AC_ARG_ENABLE([al-audio],
    [  --disable-al-audio      make a version not using al audio])
if test x"$enable_al" != x"no"; then
    case "$host" in
    *-sgi-irix*)
        LIBAO_LIBS="$LIBAO_LIBS -laudio"
        AC_DEFINE([LIBAO_AL],,[libao al support]);;
    esac
fi

dnl check for win32
AC_ARG_ENABLE([win],
    [  --disable-win           make a version not using win audio])
if test x"$enable_win" != x"no"; then
    case "$host" in
    *-mingw32*|*-cygwin)
        LIBAO_LIBS="$LIBAO_LIBS -lwinmm"
        AC_DEFINE([LIBAO_WIN],,[libao win support]);;
    esac
fi
Michel Lespinasse's avatar
Michel Lespinasse committed
212 213

AC_ARG_ENABLE([warnings],
214 215
    [  --enable-warnings       treat warnings as errors])
if test x"$enable_warnings" = x"yes" -a x"$GCC" = x"yes"; then
Michel Lespinasse's avatar
Michel Lespinasse committed
216
    dnl compiler warnings
217
    TRY_CFLAGS="$OPT_CFLAGS -Werror"
218
    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
219
elif test x"$TENDRA" = x"yes"; then
220
    dnl TenDRA portability checking compiler
221
    OPT_CFLAGS="$OPT_CFLAGS -DTenDRA_check"
Michel Lespinasse's avatar
Michel Lespinasse committed
222 223
fi

224 225 226 227 228 229 230 231 232 233
AC_SUBST([A52DEC_CFLAGS])

A52DEC_CFLAGS="$OPT_CFLAGS"

AC_ARG_ENABLE([gprof],[  --enable-gprof          make a version using gprof])
if test x"$enable_gprof" = x"yes"; then
    AC_DEFINE([A52DEC_GPROF],,[a52dec profiling])
    A52DEC_CFLAGS=`echo "$A52DEC_CFLAGS"|sed "s/-fomit-frame-pointer//g"`
    A52DEC_CFLAGS="$A52DEC_CFLAGS -p"
fi
234

Michel Lespinasse's avatar
Michel Lespinasse committed
235 236
AC_C_ATTRIBUTE_ALIGNED

237
AC_OUTPUT