added extra check for working XML LIBS flags
[platform/upstream/gstreamer.git] / configure.ac
1 AC_INIT
2 AC_CANONICAL_TARGET([])
3
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 AS_VERSION(gstreamer, GST_VERSION, 0, 4, 0, 1, GST_ERROR="-Wall", GST_ERROR="-Wall -Werror")
7 dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
8 AM_MAINTAINER_MODE
9 AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
10 AS_LIBTOOL(GST, 0, 0, 0, yes)
11
12 AC_CONFIG_SRCDIR([gst/gst.c])
13 AM_CONFIG_HEADER(config.h)
14
15 dnl Add parameters for aclocal
16 dnl (This must come after AM_INIT_AUTOMAKE, since it modifies ACLOCAL)
17 ACLOCAL="$ACLOCAL -I common/m4 $ACLOCAL_FLAGS"
18
19 AC_PROG_CC
20 AM_PROG_CC_STDC
21 AM_PROG_AS
22 AS="${CC}"
23 AC_ISC_POSIX
24
25 dnl We disable static building for development, for time savings
26 dnl *NOTE*: dnl this line before release, so release does static too
27 dnl AM_DISABLE_STATIC
28
29 AC_HEADER_STDC([])
30
31
32 dnl ##############################
33 dnl # Do automated configuration #
34 dnl ##############################
35
36 dnl Check for tools:
37 dnl ================
38
39 dnl allow for different autotools
40 AS_AUTOTOOLS_ALTERNATE()
41
42 dnl modify pkg-config path
43 AC_ARG_WITH(pkg-config-path, 
44    AC_HELP_STRING([--with-pkg-config-path],
45                   [colon-separated list of pkg-config(1) dirs]),
46    [export PKG_CONFIG_PATH=${withval}])
47
48 dnl Check for nasm
49 AC_PATH_PROG(NASM_PATH, nasm, no)
50 AC_SUBST(NASM_PATH)
51 if test x$NASM_PATH = xno; then
52   AC_MSG_WARN(Couldn't find nasm)
53   HAVE_NASM="no"
54 else AC_DEFINE(HAVE_NASM, 1, [Define if NASM, the netwide assembler, is available])
55   HAVE_NASM="yes"
56 fi
57
58 GST_DOC()
59 GST_ARCH()
60
61 dnl we require bison for building of some of the marshal files
62 AC_PATH_PROG(BISON_PATH, bison, no)
63 if test x$BISON_PATH = xno; then
64   AC_MSG_ERROR(Could not find bison)
65 fi
66
67 dnl we require flex for building the parser
68 AC_PATH_PROG(FLEX_PATH, flex, no)
69 if test x$FLEX_PATH = xno; then
70   AC_MSG_ERROR(Could not find flex)
71 fi
72
73 dnl
74 dnl We should really use AC_SYS_LARGEFILE, but the problem is
75 dnl many of the plugins don't include "config.h".  To assure
76 dnl binary compatibility, it is necessary that all gstreamer
77 dnl code be compiled with the same sizeof(off_t), so we use
78 dnl the following crude hack.
79 dnl
80
81 dnl
82 dnl GST_CFLAGS are split up as GST_EXT_CFLAGS and GST_INT_CFLAGS
83 dnl same for libs
84 dnl this is so we can make GST_CFLAGS for external modules available
85 dnl without mixing in internal (uninstalled) CFLAGS
86 dnl
87
88 AC_MSG_CHECKING(for large file support)
89 AC_TRY_RUN([
90 #define _LARGEFILE_SOURCE
91 #define _FILE_OFFSET_BITS 64
92 #include <sys/types.h>
93 int main () { return !(sizeof(off_t) == 8); }
94 ],
95 [
96 AC_MSG_RESULT(yes)
97 GST_EXT_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
98 ],
99 [
100 AC_MSG_RESULT(no)
101 ],
102 [
103 AC_MSG_RESULT(no)
104 ])
105
106 dnl Check for essential libraries first:
107 dnl ====================================
108
109 dnl === GLib 2 ===
110 dnl Minimum required version of GLib2
111 dnl required for compilation without warnings
112 GLIB2_REQ="2.0.1"
113 AC_SUBST(GLIB2_REQ)
114
115 dnl Check for glib2
116 PKG_CHECK_MODULES(GLIB2, glib-2.0 >= $GLIB2_REQ gobject-2.0 gthread-2.0 gmodule-2.0,
117   HAVE_GLIB2=yes,HAVE_GLIB2=no)
118 GLIB_LIBS=$GLIB2_LIBS
119 GLIB_CFLAGS=$GLIB2_CFLAGS
120 AC_SUBST(GLIB_LIBS)
121 AC_SUBST(GLIB_CFLAGS)
122
123 if test "x$HAVE_GLIB2" = "xno"; then
124   AC_MSG_ERROR([GStreamer requires GLib 2.0 to compile.])
125 fi
126
127 GST_PKG_DEPS="glib-2.0, gobject-2.0, gmodule-2.0, gthread-2.0"
128 AC_SUBST(GST_PKG_DEPS)
129   
130 dnl === libxml 2 ===
131 dnl Minimum required version of libxml2
132 LIBXML2_REQ="2.4.0"
133 AC_SUBST(LIBXML2_REQ)
134
135 dnl check for libxml2
136 LIBXML_PKG=', libxml-2.0'
137 PKG_CHECK_MODULES(XML, libxml-2.0 >= $LIBXML2_REQ, HAVE_LIBXML2=yes, HAVE_LIBXML2=no)
138 if test "x$HAVE_LIBXML2" = "xyes"; then
139   AC_DEFINE(HAVE_LIBXML2, 1, [Define if libxml2 is available])
140 else
141   AC_MSG_ERROR([Need libxml2 for glib2 builds -- you should be able to do without it -- this needs fixing])
142 fi
143 AC_SUBST(LIBXML_PKG)
144 AC_SUBST(XML_LIBS)
145 AC_SUBST(XML_CFLAGS)
146 dnl XML_LIBS might pull in -lz without zlib actually being on the system, so
147 dnl try if you can compile with these LIBS
148 if test "x$HAVE_LIBXML2" = "xyes"; then
149   AC_CHECK_LIB(xml2, xmlNewDoc, [],
150                [AC_MSG_ERROR([You might be missing zlib development stuff])],
151                $XML_LIBS)
152 fi
153
154 dnl popt checks
155 GST_CHECK_LIBHEADER(POPT, popt, poptStrippedArgv,, popt.h, POPT_LIBS="-lpopt",
156   AC_MSG_ERROR([popt 1.6.1 or newer is required to build gstreamer. You can
157                 download the latest version from 
158                 ftp://people.redhat.com/sopwith/popt/])
159 )
160 AC_MSG_NOTICE(Checking for POPT_TABLEEND)
161 AC_TRY_RUN([
162 #include <popt.h>
163 int main ()
164 {
165 #ifndef POPT_TABLEEND
166   return 1;
167 #else
168   return 0;
169 #endif
170 }
171 ],, [
172   dnl it failed
173   AC_MSG_ERROR([popt 1.6.1 or newer is required to build gstreamer. You can
174                 download the latest version from 
175                 ftp://people.redhat.com/sopwith/popt/])
176 ])
177
178 dnl Check for atomic.h
179 dnl Note: use AC_CHECK_HEADER not AC_CHECK_HEADERS, because the latter
180 dnl defines the wrong default symbol as well (HAVE_ASM_ATOMIC_H)
181 AC_CHECK_HEADER(asm/atomic.h, HAVE_ATOMIC_H=yes, HAVE_ATOMIC_H=no)
182 dnl Do a compile to check that it has atomic_set (eg, linux 2.0 didn't)
183 if test x$HAVE_ATOMIC_H = xyes; then
184   AC_TRY_RUN([
185 #include "asm/atomic.h"
186 main() { atomic_t t; atomic_set(&t,0); atomic_inc(&t); atomic_add(1,&t);return 0;}
187   ],, [
188     # Not successful
189     if test x$HAVE_ATOMIC_H = xyes; then
190       AC_MSG_WARN(Atomic reference counting is out of date: doing without.)
191     fi
192     HAVE_ATOMIC_H=no
193   ], [
194     # Cross compiling
195     AC_MSG_RESULT(yes)
196     AC_MSG_WARN(Can't check properly for atomic reference counting.  Assuming OK.)
197   ])
198 fi
199
200 dnl ######################################################################
201 dnl # Check command line parameters, and set shell variables accordingly #
202 dnl ######################################################################
203
204 dnl FIXME: simplify all this down using a few m4 macros
205
206 AC_ARG_ENABLE(libmmx,
207 AC_HELP_STRING([--enable-libmmx],[use libmmx, if available]),
208 [case "${enableval}" in
209   yes) USE_LIBMMX=$HAVE_LIBMMX ;;
210   no)  USE_LIBMMX=no ;;
211   *) AC_MSG_ERROR(bad value ${enableval} for --enable-libmmx) ;;
212 esac], 
213 [USE_LIBMMX=$HAVE_LIBMMX]) dnl Default value
214
215 AC_ARG_ENABLE(atomic,
216 AC_HELP_STRING([--enable-atomic],[use atomic reference counting header]),
217 [case "${enableval}" in
218   yes) USE_ATOMIC_H=$HAVE_ATOMIC_H;;
219   noset) USE_ATOMIC_H=$HAVE_ATOMIC_H;;
220   no)  USE_ATOMIC_H=no;;
221   *) AC_MSG_ERROR(bad value ${enableval} for --enable-atomic) ;;
222 esac], 
223 [USE_ATOMIC_H=$HAVE_ATOMIC_H]) dnl Default value
224
225 AC_ARG_ENABLE(plugin-builddir,
226 AC_HELP_STRING([--enable-plugin-builddir],[allow tests/demos to use non-installed plugins]),
227 [case "${enableval}" in
228   yes) PLUGINS_USE_BUILDDIR=yes ;;
229   no)  PLUGINS_USE_BUILDDIR=no ;;
230   *) AC_MSG_ERROR(bad value ${enableval} for --enable-plugin-builddir) ;;
231 esac], 
232 [PLUGINS_USE_BUILDDIR=no]) dnl Default value
233
234 GST_DEBUGINFO
235
236 AC_ARG_ENABLE(profiling,
237 AC_HELP_STRING([--enable-profiling],[adds -pg to compiler commandline, for profiling]),
238 [case "${enableval}" in
239   yes) USE_PROFILING=yes ;;
240   no)  UES_PROFILING=no ;;
241   *) AC_MSG_ERROR(bad value ${enableval} for --enable-profiling) ;;
242 esac], 
243 [USE_PROFILING=no]) dnl Default value
244
245 dnl default to building registry in the source tree if we are enabling plugin build dir
246 if test "x$PLUGINS_USE_BUILDDIR" = "xyes"; then
247   GST_CONFIG_DIR=`pwd`
248 else
249   GST_CONFIG_DIR=${sysconfdir}/gstreamer
250 fi
251 AC_ARG_WITH(configdir,
252 AC_HELP_STRING([--with-configdir],[specify path to use for plugin and command completion registries]),
253 [case "${withval}" in
254   yes) AC_MSG_ERROR(bad value ${withval} for --with-configdir) ;;
255   no) AC_MSG_ERROR(bad value ${withval} for --with-configdir) ;;
256   *) GST_CONFIG_DIR="${withval}" ;;
257 esac], 
258 [:]) dnl Default value
259
260 AS_AC_EXPAND(GST_CONFIG_DIR, $GST_CONFIG_DIR)
261 AC_MSG_NOTICE(Using $GST_CONFIG_DIR as configuration dir)
262
263
264 dnl building of tests
265 AC_ARG_ENABLE(tests,
266 AC_HELP_STRING([--disable-tests],[disable building test apps]),
267 [case "${enableval}" in
268   yes) BUILD_TESTS=yes ;;
269   no)  BUILD_TESTS=no ;;
270   *) AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;;
271 esac], 
272 [BUILD_TESTS=yes]) dnl Default value
273 AM_CONDITIONAL(BUILD_TESTS,         test "x$BUILD_TESTS" = "xyes")
274
275 dnl tests known to fail
276 AC_ARG_ENABLE(failing-tests,
277 AC_HELP_STRING([--disable-failing-tests],[disable building tests known to fail]),
278 [case "${enableval}" in
279   yes) BUILD_FAILING_TESTS=yes ;;
280   no)  BUILD_FAILING_TESTS=no ;;
281   *) AC_MSG_ERROR(bad value ${enableval} for --disable-failing-tests) ;;
282 esac], 
283 [BUILD_FAILING_TESTS=no]) dnl Default value
284 AM_CONDITIONAL(BUILD_FAILING_TESTS, test "x$BUILD_FAILING_TESTS" = "xyes")
285 if test x$BUILD_FAILING_TESTS = xyes; then
286   AC_MSG_WARN([building tests known to fail, use --disable-failing-tests to disable])
287 else
288   AC_MSG_WARN([Sissy ! By asking to not build the tests known to fail, you hereby waive your right to customer support.  If you do not agree with this EULA, please press Ctrl-C before the next line is printed.  By allowing the next line to be printed, you expressly acknowledge your acceptance of this EULA.])
289 fi
290
291 AC_ARG_ENABLE(examples,
292 AC_HELP_STRING([--disable-examples],[disable building examples]),
293 [case "${enableval}" in
294   yes) BUILD_EXAMPLES=yes ;;
295   no)  BUILD_EXAMPLES=no ;;
296   *) AC_MSG_ERROR(bad value ${enableval} for --disable-examples) ;;
297 esac], 
298 [BUILD_EXAMPLES=yes]) dnl Default value
299 AM_CONDITIONAL(BUILD_EXAMPLES,      test "x$BUILD_EXAMPLES" = "xyes")
300
301 dnl Next, check for the optional components:
302 dnl ========================================
303
304 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_LOADSAVE, true)
305 GST_SUBSYSTEM_DISABLE(LOADSAVE,[pipeline XML load/save])
306 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_TYPEFIND, true)
307 GST_SUBSYSTEM_DISABLE(TYPEFIND,[typefind plugin],)
308 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_AUTOPLUG, true)
309 GST_SUBSYSTEM_DISABLE(AUTOPLUG,[autoplugger subsystem])
310 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_PARSE, true)
311 GST_SUBSYSTEM_DISABLE(PARSE,[command-line parser])
312 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_TRACE, true)
313 GST_SUBSYSTEM_DISABLE(TRACE,[tracing subsystem])
314 translit(dnm, m, l) AM_CONDITIONAL(GST_DISABLE_REGISTRY, true)
315 GST_SUBSYSTEM_DISABLE(REGISTRY,[plugin registry])
316
317 GST_EXT_CFLAGS="$GST_EXT_CFLAGS $GST_SUBSYSTEM_DISABLE_DEFINES"
318
319 dnl ################################################
320 dnl # Set defines according to variables set above #
321 dnl ################################################
322
323
324 dnl These should be "USE_*" instead of "HAVE_*", but some packages expect
325 dnl HAVE_ and it is likely to be easier to stick with the old name
326 if test "x$USE_LIBMMX" = xyes; then
327   AC_DEFINE(HAVE_LIBMMX, 1, [Define if libmmx is available])
328 fi
329
330 if test "x$USE_ATOMIC_H" = xyes; then
331   AC_DEFINE(HAVE_ATOMIC_H, 1, [Define if atomic.h header file is available])
332 fi
333
334 dnl test if we have pthread_attr_setstack; if not use the older calls
335 AC_CHECK_LIB(pthread, pthread_attr_setstack, 
336    AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACK, 1, 
337              [Defined if libpthread has pthread_attr_setstack ()]))
338
339 dnl test if we have posix_memalign; FreeBSD doesn't
340 AC_CHECK_FUNC(posix_memalign,
341    AC_DEFINE(HAVE_POSIX_MEMALIGN, 1,
342              [Defined if we have posix_memalign ()]))
343
344 if test "x$PLUGINS_USE_BUILDDIR" = xyes; then
345   AC_DEFINE(PLUGINS_USE_BUILDDIR, 1, [Define if plugins should be loaded from the build tree - only developers should use this])
346 fi
347
348 if test "x$USE_DEBUG" = xyes; then
349    GST_INT_CFLAGS="$GST_INT_CFLAGS -g"
350 fi
351
352 if test "x$USE_PROFILING" = xyes; then
353 dnl  CFLAGS="$CFLAGS -pg -fprofile-arcs"
354   FOMIT_FRAME_POINTER=""
355 else
356   FOMIT_FRAME_POINTER="-fomit-frame-pointer"
357 fi
358
359 dnl
360 dnl AC_SUBST(FOMIT_FRAME_POINTER)
361 dnl
362
363 dnl #############################
364 dnl # Set automake conditionals #
365 dnl #############################
366
367 dnl These should be "USE_*" instead of "HAVE_*", but some packages expect
368 dnl HAVE_ and it is likely to be easier to stick with the old name
369 AM_CONDITIONAL(HAVE_ATOMIC_H,       test "x$USE_ATOMIC_H" = "xyes")
370
371 AM_CONDITIONAL(EXPERIMENTAL,        test "$EXPERIMENTAL" = "$xyes")
372 AM_CONDITIONAL(BROKEN,              test "$BROKEN" = "$xyes")
373
374 AM_CONDITIONAL(HAVE_NASM,           test "x$HAVE_NASM" = "xyes")
375 AM_CONDITIONAL(PLUGINS_USE_BUILDDIR,  test "x$PLUGINS_USE_BUILDDIR" = "xyes")
376
377
378 dnl ############################
379 dnl # Set up some more defines #
380 dnl ############################
381
382 dnl Set location of configuration dir.
383 AC_DEFINE_UNQUOTED(GST_CONFIG_DIR, "$GST_CONFIG_DIR", [Define the configuration directory])
384 AC_SUBST(GST_CONFIG_DIR)
385
386 dnl Set location of plugin directory
387 if test "x${prefix}" = "xNONE"; then
388   PLUGINS_DIR=${ac_default_prefix}/lib/gst
389 else
390   PLUGINS_DIR=${prefix}/lib/gst
391 fi
392 AC_DEFINE_UNQUOTED(PLUGINS_DIR, "$PLUGINS_DIR", [Define the plugin directory])
393 AC_SUBST(PLUGINS_DIR)
394
395 dnl Set location of uninstalled plugin directory
396 PLUGINS_BUILDDIR=`pwd`
397 AC_DEFINE_UNQUOTED(PLUGINS_BUILDDIR, "$PLUGINS_BUILDDIR", [Define the uninstalled plugin directory])
398 AC_SUBST(PLUGINS_BUILDDIR)
399
400 dnl since glib and xml are package deps, there's no need to include their cflags
401 dnl in the pkg-config file
402
403 dnl for pkg-config
404 GST_PKG_CFLAGS=$GST_EXT_CFLAGS
405 GST_PKG_LIBS=$GST_EXT_LIBS
406 AC_SUBST(GST_PKG_CFLAGS)
407 AC_SUBST(GST_PKG_LIBS)
408
409 dnl finalize _CFLAGS and _LIBS
410 dnl add GLIB and XML if necessary to EXT_*
411 GST_CFLAGS="$GST_EXT_CFLAGS $XML_CFLAGS $GLIB_CFLAGS"
412 GST_LIBS="$GST_EXT_LIBS $XML_LIBS $GLIB_LIBS -lpopt"
413
414 dnl Private vars for libgst only
415 LIBGST_LIBS="$GST_LIBS"
416 LIBGST_CFLAGS="$GST_CFLAGS -I\$(top_srcdir) $GST_ERROR"
417 AC_SUBST(LIBGST_LIBS)
418 AC_SUBST(LIBGST_CFLAGS)
419
420 dnl Vars for everyone else
421 GST_INT_LIBS="\$(top_builddir)/gst/libgstreamer.la"
422 GST_INT_CFLAGS="$GST_INT_CFLAGS -I\$(top_srcdir)/libs -I\$(top_srcdir)/include"
423
424 AC_SUBST(GST_CFLAGS, "$LIBGST_CFLAGS $GST_INT_CFLAGS")
425 AC_SUBST(GST_LIBS, "$LIBGST_LIBS $GST_INT_LIBS")
426
427 GST_PLUGIN_LDFLAGS='-module -avoid-version'
428 AC_SUBST(GST_PLUGIN_LDFLAGS)
429
430 AC_CONFIG_SUBDIRS(libs/ext/cothreads)
431
432 dnl ##################################################
433 dnl # Prepare informative messages to display at end #
434 dnl ##################################################
435
436 infomessages=
437
438 if test "x$PLUGINS_USE_BUILDDIR" = xyes; then
439   infomessages="$infomessages
440 *** Warning: You have configured using the --enable-plugin-builddir option.
441
442 This option is for development purposes only: binaries built with
443 it should be used with code in the build tree only.  To build an
444 installable version, use ./configure without the --enable-plugin-builddir
445 option.  Note that the autogen.sh script supplies the plugin builddir
446 option automatically -- run ./autogen.sh --disable-plugin-buildddir to make
447 an installable build.
448
449 "
450 fi
451
452 dnl #########################
453 dnl # Make the output files #
454 dnl #########################
455
456 dnl libs/ext/Makefile
457 AC_OUTPUT(
458 Makefile
459 include/Makefile
460 gst/Makefile
461 gst/gstversion.h
462 gst/autoplug/Makefile
463 gst/elements/Makefile
464 gst/parse/Makefile
465 gst/schedulers/Makefile
466 gst/types/Makefile
467 gst/registries/Makefile
468 libs/Makefile
469 libs/gst/Makefile
470 libs/gst/bytestream/Makefile
471 libs/gst/getbits/Makefile
472 libs/gst/putbits/Makefile
473 libs/gst/control/Makefile
474 libs/ext/Makefile
475 tests/Makefile
476 tests/bufspeed/Makefile
477 tests/memchunk/Makefile
478 tests/muxing/Makefile
479 tests/seeking/Makefile
480 tests/sched/Makefile
481 tests/threadstate/Makefile
482 testsuite/Makefile
483 testsuite/bytestream/Makefile
484 testsuite/caps/Makefile
485 testsuite/cleanup/Makefile
486 testsuite/clock/Makefile
487 testsuite/dynparams/Makefile
488 testsuite/elements/Makefile
489 testsuite/plugin/Makefile
490 testsuite/refcounting/Makefile
491 testsuite/threads/Makefile
492 examples/Makefile
493 examples/autoplug/Makefile
494 examples/helloworld/Makefile
495 examples/helloworld2/Makefile
496 examples/launch/Makefile
497 examples/queue/Makefile
498 examples/queue2/Makefile
499 examples/queue3/Makefile
500 examples/queue4/Makefile
501 examples/thread/Makefile
502 examples/mixer/Makefile
503 examples/cutter/Makefile
504 examples/launch/Makefile
505 examples/xml/Makefile
506 examples/plugins/Makefile
507 examples/typefind/Makefile
508 examples/mixer/Makefile
509 examples/pingpong/Makefile
510 tools/Makefile
511 docs/Makefile
512 docs/gst/Makefile
513 docs/gst/gstreamer.types
514 docs/libs/Makefile
515 docs/plugins/Makefile
516 docs/plugins/gstreamer-plugins.types
517 docs/manual/Makefile
518 docs/fwg/Makefile
519 docs/xsl/Makefile
520 docs/devhelp/Makefile
521 stamp.h
522 gstreamer.pc
523 gstreamer-uninstalled.pc
524 gstreamer.spec,
525 echo "$infomessages", infomessages="$infomessages"
526 )