1dnl Process this file with autoconf to produce a configure script.
2AC_PREREQ(2.54)
3AC_INIT([libmpeg2],[0.5.1],[])
4
5AC_CONFIG_SRCDIR([src/mpeg2dec.c])
6AC_CONFIG_AUX_DIR(.auto)
7AC_CONFIG_FILES([Makefile include/Makefile test/Makefile
8    doc/Makefile src/Makefile libmpeg2/Makefile libmpeg2/convert/Makefile
9    libvo/Makefile vc++/Makefile
10    libmpeg2/libmpeg2.pc libmpeg2/convert/libmpeg2convert.pc])
11AC_CONFIG_HEADERS([include/config.h])
12AC_CANONICAL_HOST
13
14AM_INIT_AUTOMAKE([1.5 -Wall foreign])
15AM_MAINTAINER_MODE
16
17dnl Checks for compiler
18AC_PROG_CC
19AC_PROG_GCC_TRADITIONAL
20AM_PROG_AS
21
22dnl Checks for headers. We do this before the CC-specific section because
23dnl autoconf generates tests for generic headers before the first header test.
24AC_CHECK_HEADERS([sys/time.h time.h sys/timeb.h io.h])
25
26dnl CC-specific flags
27AC_SUBST([OPT_CFLAGS])
28AC_SUBST([ARCH_OPT_CFLAGS])
29if test x"$CC" = x"checkergcc"; then
30    enable_sdl=no
31elif test x"$GCC" = x"yes"; then
32
33    dnl GCC-specific flags
34
35    dnl -Wall
36    dnl -Werror moved to the end to not disturb the configure script
37    TRY_CFLAGS="$OPT_CFLAGS -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare"
38    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
39
40    dnl -O3
41    changequote(<<,>>)
42    TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"|sed "s/-O[0-9]*//g"`
43    changequote([,])
44    TRY_CFLAGS="$TRY_CFLAGS -O3"
45    AC_TRY_CFLAGS([$TRY_CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
46
47    AC_ARG_ENABLE([debug],
48	[  --enable-debug          debug mode configuration])
49    if test x"$enable_debug" = x"yes"; then
50	AC_DEFINE([DEBUG],,[debug mode configuration])
51    else
52	dnl -fomit-frame-pointer
53	TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer"
54	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
55    fi
56
57    dnl -fno-common
58    TRY_CFLAGS="$OPT_CFLAGS -fno-common"
59    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
60
61    dnl arch-specific flags
62    arm_conditional=false
63    case "$host" in
64    i?86-* | k?-* | x86_64-* | amd64-*)
65	AC_DEFINE([ARCH_X86],,[x86 architecture])
66	case "$host" in
67	i386-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i386";;
68	i486-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i486";;
69	i586-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentium";;
70	i686-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentiumpro";;
71	k6-*)   TRY_CFLAGS="$OPT_CFLAGS -mcpu=k6";;
72	esac
73	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
74    ppc-* | powerpc-*)
75	have_altivec=no
76	for TRY_CFLAGS in "-mpim-altivec -force_cpusubtype_ALL" -faltivec -maltivec -fvec; do
77	    AC_TRY_CFLAGS([$OPT_CFLAGS $TRY_CFLAGS $CFLAGS],
78		[save_CFLAGS="$CFLAGS"
79		 CFLAGS="$OPT_CFLAGS $TRY_CFLAGS $CFLAGS"
80		 AC_MSG_CHECKING([if <altivec.h> is needed])
81		 AC_TRY_COMPILE([],
82		    [typedef vector int t;
83		     vec_ld(0, (unsigned char *)0);],
84		    [have_altivec=yes; AC_MSG_RESULT(no)],
85		    [AC_TRY_COMPILE([#include <altivec.h>],
86			[typedef vector int t; vec_ld(0, (unsigned char *)0);],
87			[AC_DEFINE([HAVE_ALTIVEC_H],,
88			    [Define to 1 if you have the <altivec.h> header.])
89			 have_altivec=yes; AC_MSG_RESULT(yes)],
90			[AC_MSG_RESULT(unsupported)])])
91		 CFLAGS="$save_CFLAGS"])
92	    if test "$have_altivec" = "yes"; then
93		ARCH_OPT_CFLAGS="$TRY_CFLAGS"
94		AC_DEFINE([ARCH_PPC],,[ppc architecture])
95		break
96	    fi
97	done;;
98    sparc-* | sparc64-*)
99	AC_DEFINE([ARCH_SPARC],,[sparc architecture])
100	TRY_CFLAGS="$OPT_CFLAGS -mcpu=ultrasparc -mvis"
101	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
102    alpha*)
103	AC_DEFINE([ARCH_ALPHA],,[alpha architecture]);;
104    arm*)
105	arm_conditional=:
106	AC_DEFINE([ARCH_ARM],,[ARM architecture]);;
107    esac
108elif test x"$CC" = x"tendracc"; then
109    dnl TenDRA portability checking compiler
110    TENDRA=yes
111    OPT_CFLAGS="-Xp -Yansi -f`pwd`/include/tendra.h -DELIDE_CODE"
112    no_x=yes
113    enable_sdl=no
114elif test x"$CC" = x"icc" -a x"`$CC -V 2>&1 | grep Intel`" != x""; then
115    dnl Intel C++ compiler
116    OPT_CFLAGS="-g -O3 -unroll -ip"
117else
118    dnl non-gcc flags - we probably need exact configuration triplets here.
119    case "$host" in
120    sparc-sun-solaris*)
121	TRY_CFLAGS="$OPT_CFLAGS -xCC -fast -xO5"
122	AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);;
123    esac
124fi
125
126AM_CONDITIONAL(ARCH_ARM, ${arm_conditional})
127
128dnl Checks for libtool - this must be done after we set cflags
129AC_LIBTOOL_WIN32_DLL
130AC_PROG_LIBTOOL
131
132dnl Checks for libraries.
133
134dnl Checks for header files.
135AM_CPPFLAGS='-I$(top_srcdir)/include -I$(top_builddir)/include'
136AC_SUBST([AM_CPPFLAGS])
137AC_HEADER_TIME
138AC_CHECK_TYPES([struct timeval], [], [],
139    [#include <sys/time.h>
140    #include <time.h>])
141AC_CHECK_GENERATE_INTTYPES([include])
142
143dnl Checks for typedefs, structures, and compiler characteristics.
144AC_C_CONST
145AC_C_ALWAYS_INLINE
146AC_C_RESTRICT
147AC_C_BUILTIN_EXPECT
148AC_C_BIGENDIAN
149AC_C_VOLATILE
150AC_TYPE_SIZE_T
151AC_TYPE_SIGNAL
152AC_SYS_LARGEFILE
153
154dnl Checks for library functions.
155AC_CHECK_FUNCS([gettimeofday ftime])
156
157case "$target" in
158  dnl avoid -fPIC on 32-bit x86 platforms
159  i?86-*|k?-*)
160    AC_LIBTOOL_NON_PIC([LIBMPEG2_CFLAGS="$LIBMPEG2_CFLAGS -prefer-non-pic"])
161  ;;
162esac
163AC_SUBST([LIBMPEG2_CFLAGS])
164
165dnl check for cpudetect
166AC_ARG_ENABLE([accel-detect],
167    [  --disable-accel-detect  make a version without accel detection code])
168if test x"$enable_accel_detect" != x"no"; then
169    AC_DEFINE([ACCEL_DETECT],,[autodetect accelerations])
170fi
171
172dnl check for X11
173AC_PATH_XTRA
174if test x"$no_x" != x"yes"; then
175    dnl check for Xshm
176    AC_CHECK_LIB([Xext],[XShmCreateImage],
177        [AC_DEFINE([LIBVO_X11],,[libvo X11 support])
178        LIBVO_CFLAGS="$LIBVO_CFLAGS $X_CFLAGS"
179        LIBVO_LIBS="$LIBVO_LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lXext -lX11"
180        dnl check for Xv
181        AC_CHECK_LIB([Xv],[XvShmCreateImage],
182            [AC_DEFINE([LIBVO_XV],,[libvo Xv support])
183            LIBVO_LIBS="$LIBVO_LIBS -lXv"],,
184            [$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lXext -lX11])],,
185        [$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lX11])
186fi
187
188dnl check for DirectX
189AC_ARG_ENABLE([directx],
190    [  --enable-directx=DIR    use Win32 DirectX headers in DIR])
191case $enable_directx in
192    ""|yes)     AC_CHECK_HEADER([ddraw.h],
193                    [AC_DEFINE([LIBVO_DX],,[libvo DirectX support])
194                    LIBVO_LIBS="$LIBVO_LIBS -lgdi32"]);;
195    no)         ;;
196    *)          if test -f "$enable_directx/ddraw.h"; then
197                    AC_DEFINE([LIBVO_DX],,[libvo DirectX support])
198                    LIBVO_CFLAGS="$LIBVO_CFLAGS -I$enable_directx"
199                    LIBVO_LIBS="$LIBVO_LIBS -lgdi32"
200                else
201                    AC_MSG_ERROR([Cannot find $enable_directx/ddraw.h])
202                fi;;
203esac
204
205dnl check for SDL
206AC_ARG_ENABLE([sdl],[  --disable-sdl           make a version not using SDL])
207if test x"$enable_sdl" != x"no"; then
208    AC_CHECK_PROG([SDLCONFIG],[sdl-config],[yes])
209    if test x"$SDLCONFIG" = x"yes"; then
210        AC_DEFINE([LIBVO_SDL],,[libvo SDL support])
211        LIBVO_CFLAGS="$LIBVO_CFLAGS `sdl-config --cflags`"
212        LIBVO_LIBS="$LIBVO_LIBS `sdl-config --libs`"
213    fi
214fi
215
216AC_SUBST([LIBVO_CFLAGS])
217AC_SUBST([LIBVO_LIBS])
218
219AC_ARG_ENABLE([warnings],
220    [  --enable-warnings       treat warnings as errors])
221if test x"$enable_warnings" = x"yes" -a x"$GCC" = x"yes"; then
222    dnl compiler warnings
223    TRY_CFLAGS="$OPT_CFLAGS -Werror"
224    AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"])
225elif test x"$TENDRA" = x"yes"; then
226    dnl TenDRA portability checking compiler
227    OPT_CFLAGS="$OPT_CFLAGS -DTenDRA_check"
228fi
229
230MPEG2DEC_CFLAGS="$OPT_CFLAGS"
231
232AC_ARG_ENABLE([gprof],[  --enable-gprof          make a version using gprof])
233if test x"$enable_gprof" = x"yes"; then
234    AC_DEFINE([MPEG2DEC_GPROF],,[mpeg2dec profiling])
235    MPEG2DEC_CFLAGS=`echo "$MPEG2DEC_CFLAGS"|sed "s/-fomit-frame-pointer//g"`
236    MPEG2DEC_CFLAGS="$MPEG2DEC_CFLAGS -p"
237fi
238
239AC_SUBST([MPEG2DEC_CFLAGS])
240
241AC_C_ATTRIBUTE_ALIGNED
242
243AC_OUTPUT
244