configure.ac 5.17 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([mpeg2dec],[0.5.0-cvs],[])

5
AC_CONFIG_SRCDIR([src/mpeg2dec.c])
Michel Lespinasse's avatar
Michel Lespinasse committed
6
AC_CONFIG_AUX_DIR(autotools)
7
AC_CONFIG_FILES([Makefile include/Makefile test/Makefile
8 9 10
    doc/Makefile src/Makefile libmpeg2/Makefile libmpeg2/convert/Makefile
    libvo/Makefile vc++/Makefile
    libmpeg2/libmpeg2.pc libmpeg2/convert/libmpeg2convert.pc])
Michel Lespinasse's avatar
Michel Lespinasse committed
11
AC_CONFIG_HEADERS([include/config.h])
Michel Lespinasse's avatar
Michel Lespinasse committed
12 13
AC_CANONICAL_HOST

14 15 16
AM_INIT_AUTOMAKE([1.5 -Wall foreign])
AM_MAINTAINER_MODE

Michel Lespinasse's avatar
Michel Lespinasse committed
17 18 19 20
dnl Checks for compiler
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL

21 22
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.
23
AC_CHECK_HEADERS([sys/time.h time.h sys/timeb.h io.h])
24

25
dnl CC-specific flags
26
AC_SUBST([OPT_CFLAGS])
27
AC_SUBST([ARCH_OPT_CFLAGS])
28 29 30
if test x"$CC" = x"checkergcc"; then
    enable_sdl=no
elif test x"$GCC" = x"yes"; then
Michel Lespinasse's avatar
Michel Lespinasse committed
31

32
    dnl GCC-specific flags
Michel Lespinasse's avatar
Michel Lespinasse committed
33

34
    dnl -Wall
Michel Lespinasse's avatar
.  
Michel Lespinasse committed
35
    dnl -Werror moved to the end to not disturb the configure script
36
    TRY_CFLAGS="$OPT_CFLAGS -Wall"
37
    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
38

Michel Lespinasse's avatar
Michel Lespinasse committed
39 40
    dnl -O3
    changequote(<<,>>)
41
    TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"|sed "s/-O[0-9]*//g"`
Michel Lespinasse's avatar
Michel Lespinasse committed
42
    changequote([,])
43
    TRY_CFLAGS="$TRY_CFLAGS -O3"
44
    AC_TRY_CFLAGS([$TRY_CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"; CFLAGS=""])
Michel Lespinasse's avatar
Michel Lespinasse committed
45

46 47 48 49 50 51
    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
52
	TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer"
53
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
54
    fi
Michel Lespinasse's avatar
Michel Lespinasse committed
55

56 57 58 59
    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
60
    dnl arch-specific flags
Michel Lespinasse's avatar
Michel Lespinasse committed
61
    case "$host" in
62
    i?86-* | k?-* | x86_64-* | amd64-*)
Michel Lespinasse's avatar
Michel Lespinasse committed
63
	AC_DEFINE([ARCH_X86],,[x86 architecture])
Michel Lespinasse's avatar
Michel Lespinasse committed
64
	case "$host" in
65 66 67 68 69
	i386-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i386";;
	i486-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i486";;
	i586-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentium";;
	i686-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentiumpro";;
	k6-*)   TRY_CFLAGS="$OPT_CFLAGS -mcpu=k6";;
Michel Lespinasse's avatar
Michel Lespinasse committed
70
	esac
71
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
72
    ppc-* | powerpc-*)
73
	have_altivec=no
74
	for TRY_CFLAGS in "-mpim-altivec -force_cpusubtype_ALL" -faltivec -maltivec -fvec; do
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
	    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;;
96
    sparc-* | sparc64-*)
97
	AC_DEFINE([ARCH_SPARC],,[sparc architecture])
98
	TRY_CFLAGS="$OPT_CFLAGS -mcpu=ultrasparc -mvis"
99
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
100
    alpha*)
101
	AC_DEFINE([ARCH_ALPHA],,[alpha architecture]);;
Michel Lespinasse's avatar
Michel Lespinasse committed
102
    esac
Michel Lespinasse's avatar
Michel Lespinasse committed
103
elif test x"$CC" = x"tendracc"; then
Michel Lespinasse's avatar
Michel Lespinasse committed
104
    dnl TenDRA portability checking compiler
105
    TENDRA=yes
106
    OPT_CFLAGS="-Xp -Yansi -f`pwd`/include/tendra.h -DELIDE_CODE"
Michel Lespinasse's avatar
Michel Lespinasse committed
107 108
    no_x=yes
    enable_sdl=no
Michel Lespinasse's avatar
Michel Lespinasse committed
109 110
elif test x"$CC" = x"icc" -a x"`$CC -V 2>&1 | grep Intel`" != x""; then
    dnl Intel C++ compiler
111
    OPT_CFLAGS="-g -O3 -unroll -ip"; CFLAGS=""
Michel Lespinasse's avatar
Michel Lespinasse committed
112 113
else
    dnl non-gcc flags - we probably need exact configuration triplets here.
Michel Lespinasse's avatar
Michel Lespinasse committed
114
    case "$host" in
Michel Lespinasse's avatar
Michel Lespinasse committed
115
    sparc-sun-solaris*)
116
	TRY_CFLAGS="$OPT_CFLAGS -xCC -fast -xO5"
117
	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
Michel Lespinasse's avatar
Michel Lespinasse committed
118 119 120 121
    esac
fi

dnl Checks for libtool - this must be done after we set cflags
122
AC_DISABLE_SHARED
Michel Lespinasse's avatar
Michel Lespinasse committed
123
AC_LIBTOOL_WIN32_DLL
124
AC_PROG_LIBTOOL
Michel Lespinasse's avatar
Michel Lespinasse committed
125 126 127 128 129

dnl Checks for libraries.

dnl Checks for header files.
INCLUDES='-I$(top_srcdir)/include -I$(top_builddir)/include'
130
AC_SUBST([INCLUDES])
131
AC_HEADER_TIME
132 133 134
AC_CHECK_TYPES([struct timeval], [], [],
    [#include <sys/time.h>
    #include <time.h>])
135
AC_CHECK_GENERATE_INTTYPES([include])
Michel Lespinasse's avatar
Michel Lespinasse committed
136 137 138

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
139
AC_C_ALWAYS_INLINE
140
AC_C_RESTRICT
141
AC_C_BUILTIN_EXPECT
Michel Lespinasse's avatar
Michel Lespinasse committed
142
AC_C_BIGENDIAN
Michel Lespinasse's avatar
.  
Michel Lespinasse committed
143 144 145
AC_C_VOLATILE
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
146
AC_SYS_LARGEFILE
Michel Lespinasse's avatar
Michel Lespinasse committed
147 148

dnl Checks for library functions.
149
AC_CHECK_FUNCS([gettimeofday ftime])
Michel Lespinasse's avatar
Michel Lespinasse committed
150 151 152 153 154

builtin([include],[libmpeg2/configure.incl])
builtin([include],[libvo/configure.incl])

AC_ARG_ENABLE([warnings],
155 156
    [  --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
157
    dnl compiler warnings
158
    TRY_CFLAGS="$OPT_CFLAGS -Werror"
159
    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
160
elif test x"$TENDRA" = x"yes"; then
Michel Lespinasse's avatar
Michel Lespinasse committed
161
    dnl TenDRA portability checking compiler
162
    OPT_CFLAGS="$OPT_CFLAGS -DTenDRA_check"
Michel Lespinasse's avatar
Michel Lespinasse committed
163 164
fi

165 166
builtin([include],[src/configure.incl])

Michel Lespinasse's avatar
Michel Lespinasse committed
167 168
AC_C_ATTRIBUTE_ALIGNED

169
AC_OUTPUT