configure.ac: Set AC_CONFIG_MACRO_DIR to common/m4 to point autoconf to our M4 macros.
[platform/upstream/gstreamer.git] / configure.ac
1 AC_PREREQ(2.52)
2
3 dnl initialize autoconf
4 dnl when going to/from release please set the nano (fourth number) right !
5 dnl releases only do Wall, cvs and prerelease does Werror too
6 AC_INIT(GStreamer FFMpeg, 0.10.6.1,
7     http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
8     gst-ffmpeg)
9
10 AG_GST_INIT
11
12 dnl initialize automake
13 AM_INIT_AUTOMAKE
14
15 dnl define PACKAGE_VERSION_* variables
16 AS_VERSION
17
18 dnl check if this is a release version
19 AS_NANO(GST_CVS="no", GST_CVS="yes")
20
21 dnl can autoconf find the source ?
22 AC_CONFIG_SRCDIR([ext/ffmpeg/gstffmpeg.c])
23
24 dnl where are our m4 macros ?
25 AC_CONFIG_MACRO_DIR([common/m4])
26
27 dnl define the output header for config
28 AM_CONFIG_HEADER([config.h])
29
30 dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
31 AM_MAINTAINER_MODE
32
33 dnl sets host_* variables
34 AC_CANONICAL_HOST
35
36 dnl our libraries and install dirs use major.minor as a version
37 GST_MAJORMINOR=$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR
38 dnl we override it here if we need to for the release candidate of new series
39 GST_MAJORMINOR=0.10
40 AC_SUBST(GST_MAJORMINOR)
41
42 AC_LIBTOOL_WIN32_DLL
43 AM_PROG_LIBTOOL
44
45 dnl *** required versions of GStreamer stuff ***
46 GST_REQ=0.10.13
47 LIBOIL_MAJORMINOR=0.3
48 LIBOIL_REQ=0.3.6
49
50 dnl *** autotools stuff ****
51
52 dnl allow for different autotools
53 AS_AUTOTOOLS_ALTERNATE
54
55 dnl Add parameters for aclocal
56 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I common/m4")
57
58 dnl *** check for arguments to configure ***
59
60 AG_GST_ARG_WITH_PACKAGE_NAME
61 AG_GST_ARG_WITH_PACKAGE_ORIGIN
62 AG_GST_ARG_VALGRIND
63
64 dnl *** checks for platform ***
65
66 dnl * hardware/architecture *
67
68 dnl common/m4/gst-arch.m4
69 dnl check CPU type
70 AG_GST_ARCH
71
72 dnl *** checks for programs ***
73
74 dnl find a compiler
75 AC_PROG_CC
76
77 # FIXME: are these two lines needed ?
78 AM_PROG_CC_STDC
79 AS="${CC}"
80
81 dnl check if the compiler supports '-c' and '-o' options
82 AM_PROG_CC_C_O
83
84 AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
85 AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
86
87 dnl check for documentation tools
88 AG_GST_DOCBOOK_CHECK
89 GTK_DOC_CHECK([1.3])
90 AS_PATH_PYTHON([2.1])
91 AG_GST_PLUGIN_DOCS([1.3],[2.1])
92
93 dnl *** checks for libraries ***
94
95 dnl check for libm, for sin()
96 AC_CHECK_LIBM
97 AC_SUBST(LIBM)
98
99 dnl *** checks for header files ***
100
101 dnl check if we have ANSI C header files
102 AC_HEADER_STDC
103
104 dnl *** checks for types/defines ***
105
106 dnl *** checks for structures ***
107
108 dnl *** checks for compiler characteristics ***
109
110 dnl *** checks for library functions ***
111
112 dnl *** checks for dependancy libraries ***
113
114 dnl checks for gstreamer
115 dnl uninstalled is selected preferentially -- see pkg-config(1)
116 AG_GST_CHECK_GST($GST_MAJORMINOR, [$GST_REQ])
117 AG_GST_CHECK_GST_BASE($GST_MAJORMINOR, [$GST_REQ])
118 AG_GST_CHECK_GST_PLUGINS_BASE($GST_MAJORMINOR, [$GST_REQ])
119 AG_GST_CHECK_GST_CHECK($GST_MAJORMINOR, [$GST_REQ], no)
120 AM_CONDITIONAL(HAVE_GST_CHECK, test "x$HAVE_GST_CHECK" = "xyes")
121
122 AC_MSG_NOTICE(Using GStreamer Core Plugins in $GST_PLUGINS_DIR)
123 AC_MSG_NOTICE(Using GStreamer Base Plugins in $GSTPB_PLUGINS_DIR)
124
125 dnl liboil is required for cpu detection for libpostproc
126 dnl FIXME : In theory we should be able to compile libpostproc with cpudetect
127 dnl capabilities, which would enable us to get rid of this
128 PKG_CHECK_MODULES(LIBOIL, liboil-$LIBOIL_MAJORMINOR >= $LIBOIL_REQ, HAVE_LIBOIL=yes, HAVE_LIBOIL=no)
129 if test "x$HAVE_LIBOIL" != "xyes"
130 then
131   AC_MSG_ERROR([liboil-$LIBOIL_REQ or later is required])
132   AC_ERROR
133 fi
134
135 AC_SUBST(LIBOIL_CFLAGS)
136 AC_SUBST(LIBOIL_LIBS)
137
138 dnl *** set variables based on configure arguments ***
139
140 dnl set location of plugin directory
141 AG_GST_SET_PLUGINDIR
142
143 dnl define an ERROR_CFLAGS Makefile variable
144 AG_GST_SET_ERROR_CFLAGS($GST_CVS)
145
146 dnl define correct level for debugging messages
147 AG_GST_SET_LEVEL_DEFAULT($GST_CVS)
148
149 dnl *** finalize CFLAGS, LDFLAGS, LIBS ***
150
151 dnl Overview:
152 dnl GST_OPTION_CFLAGS:  common flags for profiling, debugging, errors, ...
153 dnl GST_*:              flags shared by built objects to link against GStreamer
154 dnl GST_ALL_LDFLAGS:    linker flags shared by all
155 dnl GST_LIB_LDFLAGS:    additional linker flags for all libaries
156 dnl GST_LT_LDFLAGS:     library versioning of our libraries
157 dnl GST_PLUGIN_LDFLAGS: flags to be used for all plugins
158
159 dnl GST_OPTION_CFLAGS
160 if test "x$USE_DEBUG" = xyes; then
161    PROFILE_CFLAGS="-g"
162 fi
163 AC_SUBST(PROFILE_CFLAGS)
164
165 if test "x$GST_CVS" = "xyes"; then
166   DEPRECATED_CFLAGS="-DGST_DISABLE_DEPRECATED"
167 else
168   DEPRECATED_CFLAGS=""
169 fi
170 AC_SUBST(DEPRECATED_CFLAGS)
171
172 dnl every flag in GST_OPTION_CFLAGS can be overridden at make time
173 GST_OPTION_CFLAGS="\$(ERROR_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
174
175 AC_SUBST(GST_OPTION_CFLAGS)
176
177 dnl FIXME: do we want to rename to GST_ALL_* ?
178 dnl prefer internal headers to already installed ones
179 dnl also add builddir include for enumtypes and marshal
180 dnl add GST_OPTION_CFLAGS, but overridable
181 GST_CFLAGS="-I\$(top_srcdir)/gst-libs -I\$(top_builddir)/gst-libs $GST_CFLAGS \$(GST_OPTION_CFLAGS)"
182 AC_SUBST(GST_CFLAGS)
183 AC_SUBST(GST_LIBS)
184
185 GST_ALL_LDFLAGS="-no-undefined"
186 AC_SUBST(GST_ALL_LDFLAGS)
187
188 dnl this really should only contain flags, not libs - they get added before
189 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
190 GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^[_]*gst_plugin_desc\$\$' $GST_ALL_LDFLAGS"
191 AC_SUBST(GST_PLUGIN_LDFLAGS)
192
193 dnl Add MacOSX specific flags
194 AC_CANONICAL_HOST
195 case $host_os in
196      darwin*)
197         DARWIN_LDFLAGS="-Wl,-read_only_relocs,suppress"
198         ;;
199      *)
200         DARWIN_LDFLAGS=""
201         ;;
202 esac
203 AC_SUBST(DARWIN_LDFLAGS)
204
205 dnl *** Check for bz2
206 AG_GST_CHECK_LIBHEADER(BZ2, bz2, BZ2_bzlibVersion, , bzlib.h,, AC_ERROR([libbz2 is required]))
207
208 dnl *** configure external libs ***
209
210 HAVE_FFMPEG_UNINSTALLED=1
211
212 AC_ARG_WITH(system-ffmpeg,
213             [AC_HELP_STRING([--with-system-ffmpeg], [use system FFmpeg libraries])])
214
215 if test "x$with_system_ffmpeg" = "xyes"; then
216   PKG_CHECK_MODULES(FFMPEG, libavutil libavcodec libavformat)
217   PKG_CHECK_MODULES(POSTPROC, libavutil libavcodec libpostproc)
218   PKG_CHECK_MODULES(SWSCALE, libavutil libswscale)
219   saved_CPPFLAGS="$CPPFLAGS"
220   CPPFLAGS="$CPPFLAGS $FFMPEG_CFLAGS"
221   AC_CHECK_HEADERS([avi.h])
222   CPPFLAGS="$saved_CPPFLAGS"
223   AC_DEFINE([FFMPEG_SOURCE], ["system install"], [Describes where the FFmpeg libraries come from.])
224   HAVE_FFMPEG_UNINSTALLED=0
225   AC_MSG_NOTICE([Using system-installed FFMpeg code])
226   AC_MSG_WARN([
227   ======================================================================
228    WARNING: you have chosen to build gst-ffmpeg against a random
229    external version of ffmpeg instead of building it against the tested
230    internal ffmpeg snapshot that is included with gst-ffmpeg.
231    
232    This is a very bad idea.  So bad in fact that words cannot express
233    just how bad it is.  Suffice to say that it is BAD.
234    
235    The GStreamer developers cannot and will not support a gst-ffmpeg
236    built this way.  Any bug reports that indicate there is an external
237    version of ffmpeg involved will be closed immediately without further
238    investigation.
239    
240    The reason such a setup can't be supported is that the ffmpeg API
241    and ABI is in constant flux, yet there aren't any official releases
242    of the ffmpeg library to develop against.  This makes it impossible
243    to guarantee that gst-ffmpeg will work reliably, or even compile,
244    with a randomly picked version ffmpeg.  Even if gst-ffmpeg compiles
245    and superficially appears to work fine against your chosen external
246    ffmpeg version, that might just not be the case on other systems, or
247    even the same system at a later time, or when using decoders,
248    encoders, demuxers or muxers that have not been tested.
249    
250    Please do not create or distribute binary packages of gst-ffmpeg
251    that link against an external ffmpeg. Thank you!
252   ======================================================================
253   ])
254
255   dnl No, this is not too extreme, we want people to see and read the above
256   sleep 15
257 else
258
259   source "$srcdir/ffmpegrev"
260   
261   AC_MSG_NOTICE([Using ffmpeg revision $FFMPEG_REVISION])
262   
263   dnl libgstffmpeg.la: include dirs
264   FFMPEG_CFLAGS="-I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavformat \
265                  -I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavutil \
266                  -I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavcodec \
267                  -I \$(top_srcdir)/gst-libs/ext/ffmpeg \
268                  -Wno-deprecated-declarations"
269
270   dnl libgstffmpeg.la: libs to statically link to        
271   FFMPEG_LIBS="\$(top_builddir)/gst-libs/ext/ffmpeg/libavformat/libavformat.a \
272                \$(top_builddir)/gst-libs/ext/ffmpeg/libavcodec/libavcodec.a \
273                \$(top_builddir)/gst-libs/ext/ffmpeg/libavutil/libavutil.a"
274   dnl
275   POSTPROC_CFLAGS="-I \$(top_srcdir)/gst-libs/ext/ffmpeg/libpostproc    \
276                    -I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavutil      \
277                    -I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavcodec     \
278                    -I \$(top_srcdir)/gst-libs/ext/ffmpeg        \
279                    -Wno-deprecated-declarations"
280
281   dnl libgstpostproc.la: libs to statically link to
282   POSTPROC_LIBS="\$(top_builddir)/gst-libs/ext/ffmpeg/libpostproc/libpostproc.a \
283                  \$(top_builddir)/gst-libs/ext/ffmpeg/libavutil/libavutil.a"
284                                  
285   dnl
286   SWSCALE_CFLAGS="-I \$(top_srcdir)/gst-libs/ext/ffmpeg/libswscale      \
287                   -I \$(top_srcdir)/gst-libs/ext/ffmpeg/libavutil       \
288                   -I \$(top_srcdir)/gst-libs/ext/ffmpeg         \
289                   -Wno-deprecated-declarations"
290
291   dnl libgstswscale.la: libs to statically link to
292   SWSCALE_LIBS="\$(top_builddir)/gst-libs/ext/ffmpeg/libswscale/libswscale.a \
293                 \$(top_builddir)/gst-libs/ext/ffmpeg/libavutil/libavutil.a"
294
295   FFMPEG_SUBDIRS=gst-libs
296   AC_DEFINE(HAVE_AVI_H)
297   AC_DEFINE([FFMPEG_SOURCE], ["local snapshot"], [Describes where the FFmpeg libraries come from.])
298
299   AC_ARG_WITH(ffmpeg-extra-configure, 
300       AC_HELP_STRING([--with-ffmpeg-extra-configure="xxx"],
301       [extra configure options for internal ffmpeg ./configure script]),,
302       with_ffmpeg_extra_configure=no)
303
304   # Enable shared and static so that we get .a files, but with PIC code.
305   ac_configure_args="$ac_configure_args --disable-vhook --disable-ffserver --disable-ffplay --enable-postproc --enable-swscale --enable-gpl --enable-static --enable-shared --disable-encoder=flac --disable-decoder=cavs --disable-protocols --disable-devices --disable-network"
306
307   # if we are cross-compiling, tell ffmpeg so
308   if test "x$cross_compiling" = xyes; then
309     ac_configure_args="$ac_configure_args --enable-cross-compile \
310         --target-os=$host_os --arch=$host_cpu --cross-prefix=$host_alias-"
311   fi
312
313   case $host_os in
314     # Unfortunately, in Mac OS 10.5 the current rev of ffmpeg builds
315     # some non-PIC code into the .a file. See
316     # http://trac.macosforge.org/projects/macports/ticket/13725 for more
317     # info.
318     darwin*) 
319       ac_configure_args="$ac_configure_args --disable-mmx --disable-altivec"
320       ;;
321     mingw32*)
322       ac_configure_args="$ac_configure_args --enable-memalign-hack"
323       WIN32_LIBS="-lws2_32"
324       ;;
325     *)
326       WIN32_LIBS=
327       ;;
328   esac
329
330   # append extra configure options to ac_configure_args if needed
331   if test "x$with_ffmpeg_extra_configure" != no; then
332     ac_configure_args="$ac_configure_args $with_ffmpeg_extra_configure"
333   fi
334
335   AC_SUBST(FFMPEG_CO_DIR)
336   AC_SUBST(FFMPEG_SVN)
337   AC_SUBST(FFMPEG_REVISION)
338   AC_CONFIG_SUBDIRS(gst-libs/ext/ffmpeg)
339   AC_MSG_NOTICE([Using included FFMpeg code])
340 fi
341
342 AC_SUBST(FFMPEG_CFLAGS)
343 AC_SUBST(FFMPEG_LIBS)
344 AC_SUBST(FFMPEG_SUBDIRS)
345 AC_SUBST(POSTPROC_CFLAGS)
346 AC_SUBST(POSTPROC_LIBS)
347 AC_SUBST(SWSCALE_CFLAGS)
348 AC_SUBST(SWSCALE_LIBS)
349 AC_SUBST(WIN32_LIBS)
350  
351 if test x$HAVE_FFMPEG_UNINSTALLED = x1; then
352   AC_DEFINE(HAVE_FFMPEG_UNINSTALLED, [], [Defined if building against uninstalled FFmpeg source])
353 fi
354 AM_CONDITIONAL(HAVE_FFMPEG_UNINSTALLED, test x$HAVE_FFMPEG_UNINSTALLED = x1)
355
356 AC_CONFIG_FILES(
357 Makefile
358 gst-ffmpeg.spec
359 ext/Makefile
360 ext/ffmpeg/Makefile
361 ext/libpostproc/Makefile
362 ext/libswscale/Makefile
363 gst-libs/Makefile
364 gst-libs/ext/Makefile
365 docs/Makefile
366 docs/version.entities
367 common/Makefile
368 common/m4/Makefile
369 tests/Makefile
370 tests/check/Makefile
371 )
372 AC_OUTPUT
373