check: add macro to check for memory refcount
[platform/upstream/gstreamer.git] / configure.ac
1 AC_PREREQ(2.60)
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, git and prerelease does Werror too
6 AC_INIT(GStreamer, 0.11.1.1,
7     http://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer,
8     gstreamer)
9 AG_GST_INIT
10
11 dnl initialize automake (we require GNU make)
12 AM_INIT_AUTOMAKE([-Wno-portability 1.10])
13
14 dnl define PACKAGE_VERSION_* variables
15 AS_VERSION
16
17 dnl check if this is a release version
18 AS_NANO(GST_GIT="no", GST_GIT="yes")
19
20 dnl can autoconf find the source ?
21 AC_CONFIG_SRCDIR([gst/gst.c])
22
23 dnl define the output header for config
24 AM_CONFIG_HEADER([config.h])
25
26 dnl AM_MAINTAINER_MODE only provides the option to configure to enable it
27 AM_MAINTAINER_MODE
28
29 dnl sets host_* variables
30 AC_CANONICAL_HOST
31
32 dnl use pretty build output with automake >= 1.11
33 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],
34   [AM_DEFAULT_VERBOSITY=1
35    AC_SUBST(AM_DEFAULT_VERBOSITY)])
36
37 dnl our libraries and install dirs use major.minor as a version
38 GST_MAJORMINOR=$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR
39 dnl we override it here for release candidates for a new series
40 GST_MAJORMINOR=0.11
41 AC_SUBST(GST_MAJORMINOR)
42 AC_DEFINE_UNQUOTED(GST_MAJORMINOR, "$GST_MAJORMINOR",
43   [library major.minor version])
44
45 dnl CURRENT, REVISION, AGE
46 dnl - library source changed -> increment REVISION
47 dnl - interfaces added/removed/changed -> increment CURRENT, REVISION = 0
48 dnl - interfaces added -> increment AGE
49 dnl - interfaces removed -> AGE = 0
50 dnl sets GST_LT_LDFLAGS
51 AS_LIBTOOL(GST, 31, 0, 0)
52
53 dnl FIXME: this macro doesn't actually work;
54 dnl the generated libtool script has no support for the listed tags.
55 dnl So this needs to be fixed first if we want to use this
56 dnl AS_LIBTOOL_TAGS
57
58 AC_LIBTOOL_WIN32_DLL
59 AM_PROG_LIBTOOL
60
61 dnl *** autotools stuff ****
62
63 dnl allow for different autotools
64 AS_AUTOTOOLS_ALTERNATE
65
66 dnl Add parameters for aclocal (keep in sync with Makefile.am)
67 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4 -I common/m4")
68
69 dnl set up gettext
70 dnl the version check needs to stay here because autopoint greps for it
71 AM_GNU_GETTEXT_VERSION([0.17])
72 AM_GNU_GETTEXT([external])
73 AG_GST_GETTEXT([gstreamer-$GST_MAJORMINOR])
74
75 dnl *** check for arguments to configure ***
76
77 dnl subsystems - can influence other decisions so needs to be high up
78 dnl we need to AM_CONDITIONAL them here for automake 1.6.x compatibility
79 AG_GST_CHECK_SUBSYSTEM_DISABLE(GST_DEBUG,[debugging subsystem])
80 AM_CONDITIONAL(GST_DISABLE_GST_DEBUG, test "x$GST_DISABLE_GST_DEBUG" = "xyes")
81 AG_GST_CHECK_SUBSYSTEM_DISABLE(PARSE,[command-line parser])
82 AM_CONDITIONAL(GST_DISABLE_PARSE, test "x$GST_DISABLE_PARSE" = "xyes")
83 if test "x$GST_DISABLE_PARSE" = xyes; then
84   AC_DEFINE(GST_DISABLE_PARSE, 1,
85     [Define if pipeline parsing code is disabled])
86 fi
87 AG_GST_CHECK_SUBSYSTEM_DISABLE(OPTION_PARSING,[option parsing when gst_init])
88 AM_CONDITIONAL(GST_DISABLE_OPTION_PARSING, test "x$GST_DISABLE_OPTION_PARSING" = "xyes")
89 if test "x$GST_DISABLE_OPTION_PARSING" = xyes; then
90   AC_DEFINE(GST_DISABLE_OPTION_PARSING, 1,
91     [Define if option parsing is disabled])
92 fi
93 AG_GST_CHECK_SUBSYSTEM_DISABLE(TRACE,[tracing subsystem])
94 AM_CONDITIONAL(GST_DISABLE_TRACE, test "x$GST_DISABLE_TRACE" = "xyes")
95 AG_GST_CHECK_SUBSYSTEM_DISABLE(ALLOC_TRACE,[allocation tracing])
96 AM_CONDITIONAL(GST_DISABLE_ALLOC_TRACE, test "x$GST_DISABLE_ALLOC_TRACE" = "xyes")
97 AG_GST_CHECK_SUBSYSTEM_DISABLE(REGISTRY,[plugin registry])
98 AM_CONDITIONAL(GST_DISABLE_REGISTRY, test "x$GST_DISABLE_REGISTRY" = "xyes")
99 dnl define a substitution to use in docs/gst/gstreamer.types
100 if test "x$GST_DISABLE_REGISTRY" = "xyes"
101 then
102   GST_REGISTRY_DOC_TYPES="%"
103 else
104   GST_REGISTRY_DOC_TYPES=
105 fi
106 AC_SUBST(GST_REGISTRY_DOC_TYPES)
107 AG_GST_CHECK_SUBSYSTEM_DISABLE(NET,[network distribution])
108 AM_CONDITIONAL(GST_DISABLE_NET, test "x$GST_DISABLE_NET" = "xyes")
109 AG_GST_CHECK_SUBSYSTEM_DISABLE(PLUGIN,[plugin])
110 AM_CONDITIONAL(GST_DISABLE_PLUGIN, test "x$GST_DISABLE_PLUGIN" = "xyes")
111
112 AG_GST_ARG_DEBUG
113 AG_GST_ARG_PROFILING
114 AG_GST_ARG_VALGRIND
115 AG_GST_ARG_GCOV
116
117 AG_GST_ARG_EXAMPLES
118
119 AG_GST_ARG_WITH_PKG_CONFIG_PATH
120 AG_GST_ARG_WITH_PACKAGE_NAME
121 AG_GST_ARG_WITH_PACKAGE_ORIGIN
122
123 AG_GST_PKG_CONFIG_PATH
124
125 AG_GST_SET_PACKAGE_RELEASE_DATETIME_WITH_NANO([$PACKAGE_VERSION_NANO],
126   ["${srcdir}/gstreamer.doap"],
127   [$PACKAGE_VERSION_MAJOR.$PACKAGE_VERSION_MINOR.$PACKAGE_VERSION_MICRO])
128
129 dnl building of tests
130 AC_ARG_ENABLE(tests,
131   AC_HELP_STRING([--disable-tests], [disable building test apps]),
132   [
133     case "${enableval}" in
134       yes) BUILD_TESTS=yes ;;
135       no)  BUILD_TESTS=no ;;
136       *)   AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;;
137     esac
138   ],
139 [BUILD_TESTS=yes]) dnl Default value
140 AM_CONDITIONAL(BUILD_TESTS,         test "x$BUILD_TESTS" = "xyes")
141
142 dnl tests known to fail
143 AC_ARG_ENABLE(failing-tests,
144   AC_HELP_STRING([--disable-failing-tests],
145     [disable building tests known to fail]),
146   [
147     case "${enableval}" in
148       yes) BUILD_FAILING_TESTS=yes ;;
149       no)  BUILD_FAILING_TESTS=no ;;
150       *)   AC_MSG_ERROR(bad value ${enableval} for --disable-failing-tests) ;;
151     esac
152   ],
153   [BUILD_FAILING_TESTS=no]) dnl Default value
154 AM_CONDITIONAL(BUILD_FAILING_TESTS, test "x$BUILD_FAILING_TESTS" = "xyes")
155 if test x$BUILD_FAILING_TESTS = xyes; then
156   AC_MSG_WARN([building tests known to fail, use --disable-failing-tests to disable])
157 else
158   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.])
159 fi
160
161 dnl poison destroyed objects
162 AC_ARG_ENABLE(poisoning,
163   AC_HELP_STRING([--enable-poisoning],
164     [enable poisoning of deallocated objects]),
165   [
166     case "${enableval}" in
167       yes) USE_POISONING=yes ;;
168       no)  USE_POISONING=no ;;
169       *)   AC_MSG_ERROR(bad value ${enableval} for --enable-poisoning) ;;
170     esac
171   ],
172   [USE_POISONING=no]) dnl Default value
173 if test "x$USE_POISONING" = xyes; then
174   AC_DEFINE(USE_POISONING, 1,
175     [Define if we should poison deallocated memory])
176 fi
177
178 dnl *** checks for platform ***
179
180 dnl * hardware/architecture *
181
182 dnl common/m4/gst-arch.m4
183 dnl check CPU type
184 AG_GST_ARCH
185 dnl substitution for win32/common/config.h
186 HOST_CPU=$host_cpu
187 AC_SUBST(HOST_CPU)
188
189 dnl common/m4/gst-arch.m4
190 dnl check for unaligned access
191 AG_GST_UNALIGNED_ACCESS
192 dnl create a configure variable for gst/gstconfig.h
193 if test x${as_cv_unaligned_access} = xyes ; then
194   GST_HAVE_UNALIGNED_ACCESS_DEFINE="#define GST_HAVE_UNALIGNED_ACCESS 1"
195 else
196   GST_HAVE_UNALIGNED_ACCESS_DEFINE="#define GST_HAVE_UNALIGNED_ACCESS 0"
197 fi
198 AC_SUBST(GST_HAVE_UNALIGNED_ACCESS_DEFINE)
199
200 dnl check for platform specific settings
201 AG_GST_PLATFORM
202
203 dnl * software *
204
205 dnl check for large file support
206 dnl affected plugins must include config.h
207 AC_SYS_LARGEFILE
208
209 dnl *** checks for programs ***
210
211 dnl find a compiler
212 AC_PROG_CC
213 AC_PROG_CC_STDC
214
215 dnl check if the compiler supports '-c' and '-o' options
216 AM_PROG_CC_C_O
217
218 dnl find an assembler
219 AM_PROG_AS
220
221 dnl determine if c++ is available on this system
222 AC_PROG_CXX
223 dnl CXX may be set to some default even if no c++ compiler is available
224 dnl (thanks autotools!), so just try to compile some c++ code to make sure
225 AC_LANG_PUSH([C++])
226 AC_TRY_COMPILE([ class Foo { int bar; };], , working_cxx=yes, working_cxx=no)
227 AC_LANG_POP([C++])
228 AC_MSG_NOTICE([working c++ compiler found: $working_cxx])
229 AM_CONDITIONAL(HAVE_CXX, test "x$working_cxx" = "xyes")
230
231 dnl Perl is used in building documentation and in the version checks
232 AC_PATH_PROG(PERL_PATH, perl, no)
233 if test x$PERL_PATH = xno; then
234   AC_MSG_ERROR(Could not find perl)
235 fi
236
237 dnl we require flex and bison for building the parser
238 if test "x$GST_DISABLE_PARSE" != xyes; then
239   AG_GST_BISON_CHECK
240   AG_GST_FLEX_CHECK
241 fi
242
243 AC_PATH_PROG(VALGRIND_PATH, valgrind, no)
244 AM_CONDITIONAL(HAVE_VALGRIND, test ! "x$VALGRIND_PATH" = "xno")
245
246 dnl check for gobject-introspection
247 GOBJECT_INTROSPECTION_CHECK([1.31.1])
248
249 dnl check for documentation tools
250 AG_GST_DOCBOOK_CHECK
251 GTK_DOC_CHECK([1.3])
252 AS_PATH_PYTHON([2.1])
253 AG_GST_PLUGIN_DOCS([1.3],[2.1])
254
255 dnl *** checks for libraries ***
256
257 dnl check for libm, for sin()
258 AC_CHECK_LIBM
259 AC_SUBST(LIBM)
260
261 dnl *** checks for header files ***
262
263 dnl check if we have ANSI C header files
264 AC_HEADER_STDC
265
266 dnl Check for ucontext.h
267 AC_CHECK_HEADERS([ucontext.h])
268
269 dnl Check for sys/socket.h
270 AC_CHECK_HEADERS([sys/socket.h], HAVE_SYS_SOCKET_H=yes)
271 AM_CONDITIONAL(HAVE_SYS_SOCKET_H, test "x$HAVE_SYS_SOCKET_H" = "xyes")
272
273 dnl check for sys/times.h for tests/examples/adapter/
274 AC_CHECK_HEADERS([sys/times.h], HAVE_SYS_TIMES_H=yes)
275 AC_CHECK_HEADERS([unistd.h], HAVE_UNISTD_H=yes)
276 AM_CONDITIONAL(HAVE_SYS_TIMES_H_AND_UNISTD_H, test "x$HAVE_SYS_TIMES_H" = "xyes" -a "x$HAVE_UNISTD_H" = "xyes")
277
278 dnl Check for process.h for getpid() on win32
279 AC_CHECK_HEADERS([process.h])
280
281 dnl Check for sys/utsname.h for uname
282 AC_CHECK_HEADERS([sys/utsname.h])
283
284 dnl Check for stdio_ext.f for __fbufsize
285 AC_CHECK_HEADERS([stdio_ext.h])
286
287 dnl check for pthreads
288 AC_CHECK_HEADERS([pthread.h], HAVE_PTHREAD_H=yes)
289 AM_CONDITIONAL(HAVE_PTHREAD_H, test "x$HAVE_PTHREAD_H" = "xyes")
290
291 dnl check for sys/prctl for setting thread name on Linux
292 AC_CHECK_HEADERS([sys/prctl.h], HAVE_SYS_PRCTL_H=yes)
293
294 dnl Check for valgrind.h
295 dnl separate from HAVE_VALGRIND because you can have the program, but not
296 dnl the dev package
297 AC_CHECK_HEADERS([valgrind/valgrind.h], HAVE_VALGRIND_H=yes)
298
299 dnl used in gst/gstpoll.c
300 AC_CHECK_HEADERS([winsock2.h], HAVE_WINSOCK2_H=yes)
301 AM_CONDITIONAL(HAVE_WINSOCK2_H, test "x$HAVE_WINSOCK2_H" = "xyes")
302 if test "x$HAVE_WINSOCK2_H" = "xyes"; then
303   WIN32_LIBS="-lws2_32"
304   AC_SUBST(WIN32_LIBS)
305 fi
306
307 dnl check for GMP/GSL, used by the gst_util_uint64_scale unit test only
308 if test "x$BUILD_TESTS" = "xyes"; then
309   AG_GST_CHECK_LIBHEADER(GMP, gmp,
310                          __gmpz_init_set_d, ,
311                          gmp.h,
312                          GMP_LIBS="-lgmp"
313                          AC_SUBST(GMP_LIBS)
314                          AC_DEFINE(HAVE_GMP, [1],[Have GMP library]))
315   AG_GST_CHECK_LIBHEADER(GSL, gsl,
316                          gsl_rng_uniform_int, -lgslcblas,
317                          gsl/gsl_rng.h,
318                          GSL_LIBS="-lgsl -lgslcblas"
319                          AC_SUBST(GSL_LIBS)
320                          AC_DEFINE(HAVE_GSL, [1],[Have GSL library]))
321 fi
322
323 dnl *** checks for types/defines ***
324
325 dnl *** checks for structures ***
326
327 dnl *** checks for compiler characteristics ***
328
329 dnl check if the compiler supports __uint128_t (gcc)
330 dnl Actually check for 128-bit division, since that's what we use
331 dnl uint128_t for.
332 AC_CACHE_CHECK(for __uint128_t, gst_cv_uint128_t,
333     AC_TRY_LINK([ ], [
334       static __uint128_t v1 = 100;
335       static __uint128_t v2 = 10;
336       static __uint128_t u;
337       u = v1 / v2;
338     ], [
339       gst_cv_uint128_t=yes
340     ], [
341       gst_cv_uint128_t=no
342     ])
343 )
344 if test x$gst_cv_uint128_t = xyes; then
345   AC_DEFINE(HAVE_UINT128_T, 1, [Have __uint128_t type])
346 fi
347
348 dnl *** checking for tm_gmtoff ***
349 AC_MSG_CHECKING([for tm_gmtoff])
350 AC_RUN_IFELSE([AC_LANG_SOURCE([[
351         #include <time.h>
352         int main(void) {
353           struct tm t;
354           t.tm_gmtoff = 0;
355           exit(0);
356         }]])],
357   [have_tm_gmtoff=yes
358    AC_DEFINE(HAVE_TM_GMTOFF,1,[Have tm_gmtoff field in struct tm])],
359   [have_tm_gmtoff=no],
360   [have_tm_gmtoff="no (cross compiling)"])
361 AC_MSG_RESULT($have_tm_gmtoff)
362
363
364 dnl *** checks for library functions ***
365
366 AC_CHECK_FUNCS([gmtime_r])
367 AC_CHECK_FUNCS([localtime_r])
368 AC_CHECK_FUNCS([sigaction])
369
370 dnl check for fseeko()
371 AC_FUNC_FSEEKO
372 dnl check for ftello()
373 AC_CHECK_FUNCS([ftello])
374
375 AC_CHECK_FUNCS([fgetpos])
376 AC_CHECK_FUNCS([fsetpos])
377
378 dnl check for poll(), ppoll() and pselect()
379 AC_CHECK_FUNCS([poll])
380 AC_CHECK_FUNCS([ppoll])
381 AC_CHECK_FUNCS([pselect])
382
383 dnl ****************************************
384 dnl *** GLib POLL* compatibility defines ***
385 dnl ****************************************
386
387 AC_MSG_CHECKING([for broken poll])
388 AC_RUN_IFELSE([AC_LANG_SOURCE([[
389         #include <stdlib.h>
390         #include <fcntl.h>
391         #include <poll.h>
392         #ifdef HAVE_SYS_POLL_H
393         #include <sys/poll.h>
394         #endif
395         int main(void) {
396           struct pollfd fds[1];
397           int fd;
398           fd = open("/dev/null", 1);
399           fds[0].fd = fd;
400           fds[0].events = POLLIN;
401           fds[0].revents = 0;
402           if (poll(fds, 1, 0) < 0 || (fds[0].revents & POLLNVAL) != 0) {
403                 exit(1);  /* Does not work for devices -- fail */
404           }
405           exit(0);
406         }]])],
407   [broken_poll=no],
408   [broken_poll=yes
409    AC_DEFINE(BROKEN_POLL,1,[poll doesn't work on devices])],
410   [broken_poll="no (cross compiling)"])
411 AC_MSG_RESULT($broken_poll)
412
413 dnl check for mmap()
414 AC_FUNC_MMAP
415 AM_CONDITIONAL(HAVE_MMAP, test "x$ac_cv_func_mmap_fixed_mapped" = "xyes")
416
417 dnl check for posix_memalign(), getpagesize()
418 AC_CHECK_FUNCS([posix_memalign])
419 AC_CHECK_FUNCS([getpagesize])
420
421 dnl Check for POSIX timers
422 AC_CHECK_FUNCS(clock_gettime, [], [
423   AC_CHECK_LIB(rt, clock_gettime, [
424     AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
425     LIBS="$LIBS -lrt"
426   ])
427 ])
428
429 AC_CACHE_CHECK(for posix timers, gst_cv_posix_timers,
430     AC_TRY_COMPILE([
431 #include <time.h>
432 #ifdef HAVE_UNISTD_H
433 #include <unistd.h>
434 #endif
435     ], [
436 #if !defined(_POSIX_TIMERS) || _POSIX_TIMERS < 0 || !defined(CLOCK_REALTIME)
437 #error Either _POSIX_TIMERS or CLOCK_REALTIME not defined
438 #endif
439     ], [
440       gst_cv_posix_timers=yes
441     ], [
442       gst_cv_posix_timers=no
443     ])
444 )
445
446 if test "$gst_cv_posix_timers" = "yes"; then
447   AC_DEFINE(HAVE_POSIX_TIMERS,1,[Have posix timers])
448   GST_HAVE_POSIX_TIMERS_DEFINE="#define GST_HAVE_POSIX_TIMERS 1"
449 else
450   GST_HAVE_POSIX_TIMERS_DEFINE="#define GST_HAVE_POSIX_TIMERS 0"
451 fi
452 AC_SUBST(GST_HAVE_POSIX_TIMERS_DEFINE)
453 AM_CONDITIONAL(GST_HAVE_POSIX_TIMERS, test "$gst_cv_posix_timers" = "yes")
454
455 AC_CACHE_CHECK(for monotonic clock, gst_cv_monotonic_clock,
456     AC_TRY_COMPILE([
457 #include <time.h>
458 #ifdef HAVE_UNISTD_H
459 #include <unistd.h>
460 #endif
461     ], [
462 #if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK < 0 || !defined(CLOCK_MONOTONIC)
463 #error Either _POSIX_MONOTONIC_CLOCK or CLOCK_MONOTONIC not defined
464 #endif
465     ], [
466       gst_cv_monotonic_clock=yes
467     ], [
468       gst_cv_monotonic_clock=no
469     ])
470 )
471
472 if test "$gst_cv_monotonic_clock" = "yes"; then
473   AC_DEFINE(HAVE_MONOTONIC_CLOCK,1,[Have a monotonic clock])
474   GST_HAVE_MONOTONIC_CLOCK_DEFINE="#define GST_HAVE_MONOTONIC_CLOCK 1"
475 else
476   GST_HAVE_MONOTONIC_CLOCK_DEFINE="#define GST_HAVE_MONOTONIC_CLOCK 0"
477 fi
478 AC_SUBST(GST_HAVE_MONOTONIC_CLOCK_DEFINE)
479 AM_CONDITIONAL(GST_HAVE_MONOTONIC_CLOCK, test "$gst_cv_monotonic_clock" = "yes")
480
481 dnl Check for a way to display the function name in debug output
482 AG_GST_CHECK_FUNCTION
483
484 dnl test for register_printf_specifier or register_printf_function
485 AC_CHECK_FUNCS([register_printf_specifier register_printf_function],
486     [HAVE_PRINTF_EXTENSION=yes])
487
488 if test "$HAVE_PRINTF_EXTENSION" = yes; then
489   GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"P\""
490   GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"Q\""
491   GST_USING_PRINTF_EXTENSION_DEFINE="#define GST_USING_PRINTF_EXTENSION"
492   AC_DEFINE(HAVE_PRINTF_EXTENSION, 1,
493       [Defined if we have printf specifier extensions available])
494 else
495     GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE="#define GST_PTR_FORMAT \"p\""
496     GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE="#define GST_SEGMENT_FORMAT \"p\""
497     GST_USING_PRINTF_EXTENSION_DEFINE="#undef GST_USING_PRINTF_EXTENSION"
498 fi
499 AC_SUBST(GST_PRINTF_EXTENSION_POINTER_FORMAT_DEFINE)
500 AC_SUBST(GST_PRINTF_EXTENSION_SEGMENT_FORMAT_DEFINE)
501 AC_SUBST(GST_USING_PRINTF_EXTENSION_DEFINE)
502
503 dnl test if we have dladdr(); we use it for debugging; see gst/gstinfo.c
504 save_cflags="$CFLAGS"
505 CFLAGS="$CFLAGS -D_GNU_SOURCE"
506 AC_CHECK_LIB(dl, dladdr,
507    AC_DEFINE(HAVE_DLADDR, 1, [Defined if we have dladdr ()])
508    LIBS="$LIBS -ldl")
509 CFLAGS="$save_cflags"
510
511 dnl *** checks for socket and nsl libraries ***
512 AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
513 AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
514
515 dnl check for inet_aton()
516 save_libs="$LIBS"
517 AC_CHECK_FUNC(inet_aton, ,
518    AC_CHECK_LIB(nsl, inet_aton, ,
519       AC_CHECK_LIB(socket, inet_aton, ,
520          AC_CHECK_LIB(resolv, inet_aton, ,[AC_DEFINE(NO_INET_ATON, 1, [Define if you have no native inet_aton() function.])]))))
521 INET_ATON_LIBS=$LIBS
522 AC_SUBST(INET_ATON_LIBS)
523 LIBS="$save_libs"
524
525 dnl *** checks for dependency libraries ***
526
527 dnl GLib
528 GLIB_REQ=2.26
529
530 AG_GST_GLIB_CHECK([$GLIB_REQ])
531
532 dnl Check for glib2 without extra fat, useful for the unversioned tool frontends
533 PKG_CHECK_MODULES(GLIB_ONLY, glib-2.0 >= $GLIB_REQ)
534
535 dnl Check for documentation xrefs
536 GLIB_PREFIX="`$PKG_CONFIG --variable=prefix glib-2.0`"
537 AC_SUBST(GLIB_PREFIX)
538
539 dnl building of unit test libraries
540 AC_ARG_ENABLE(check,
541   AC_HELP_STRING([--disable-check], [disable building unit test libraries]),
542   [
543     case "${enableval}" in
544       yes) BUILD_CHECK=yes ;;
545       no)  BUILD_CHECK=no ;;
546       *)   AC_MSG_ERROR(bad value ${enableval} for --disable-check) ;;
547     esac
548   ], [
549     dnl Default value
550     case $host_os in
551       mingw* | msvc* | mks*) BUILD_CHECK=no ;;
552       *) BUILD_CHECK=yes ;;
553     esac
554 ])
555 dnl bit of a misnomer, but keep the conditional named like this so we don't
556 dnl have to change too much elsewhere
557 AM_CONDITIONAL(HAVE_CHECK, test "x$BUILD_CHECK" = "xyes")
558
559 dnl configure the desired memory alignment
560 AC_ARG_WITH([memory-alignment],
561   AS_HELP_STRING([--with-memory-alignment],[8,N,malloc,pagesize (default is 32)]),
562   [
563     if test "x$withval" = "xyes"
564     then
565       AC_DEFINE(MEMORY_ALIGNMENT, 32, [Memory alignment to use])
566     else
567       case "${withval}" in
568         malloc) AC_DEFINE(MEMORY_ALIGNMENT_MALLOC, 1, [Memory alignment by malloc default]) ;;
569         pagesize)  AC_DEFINE(MEMORY_ALIGNMENT_PAGESIZE, 1, [Memory alignment by pagesize]) ;;
570         *)   AC_DEFINE_UNQUOTED(MEMORY_ALIGNMENT, ${withval}, [Memory alignment to use]) ;;
571       esac
572     fi
573   ], [
574     AC_DEFINE(MEMORY_ALIGNMENT_MALLOC, 1, [Memory alignment by malloc default]) 
575   ]
576 )
577
578 dnl Check for -Bsymbolic-functions linker flag used to avoid
579 dnl intra-library PLT jumps, if available.
580 AC_ARG_ENABLE(Bsymbolic,
581               [AC_HELP_STRING([--disable-Bsymbolic],
582                               [avoid linking with -Bsymbolic])],,
583               [SAVED_LDFLAGS="${LDFLAGS}"
584                AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
585                LDFLAGS=-Wl,-Bsymbolic-functions
586                AC_TRY_LINK([], [int main (void) { return 0; }],
587                            AC_MSG_RESULT(yes)
588                            enable_Bsymbolic=yes,
589                            AC_MSG_RESULT(no)
590                            enable_Bsymbolic=no)
591                LDFLAGS="${SAVED_LDFLAGS}"])
592
593
594 dnl *** set variables based on configure arguments
595
596 dnl set license and copyright notice
597 GST_LICENSE="LGPL"
598 AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer license])
599 AC_SUBST(GST_LICENSE)
600
601 dnl define LIBDIR, GST_DATADIR so we can inform people where we live
602 AS_AC_EXPAND(LIBDIR, $libdir)
603 AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [library dir])
604 AS_AC_EXPAND(DATADIR, $datadir)
605 AC_DEFINE_UNQUOTED(GST_DATADIR, "$DATADIR", [data dir])
606
607 dnl set location of plugin directory
608 AG_GST_SET_PLUGINDIR
609
610 GST_PKG_DEPS="glib-2.0, gobject-2.0, gmodule-no-export-2.0, gthread-2.0"
611 AC_SUBST(GST_PKG_DEPS)
612
613 dnl make sure it doesn't complain about unused variables if debugging is disabled
614 NO_WARNINGS=""
615 if test "x${GST_DISABLE_GST_DEBUG}" = "xyes"; then
616   NO_WARNINGS="-Wno-unused"
617 fi
618
619 dnl define an ERROR_CFLAGS Makefile variable
620 AG_GST_SET_ERROR_CFLAGS($GST_GIT, [-Wmissing-declarations -Wmissing-prototypes -Wredundant-decls -Wundef -Wwrite-strings -Wformat-nonliteral -Wformat-security -Wold-style-definition -Winit-self -Wmissing-include-dirs -Waddress -Waggregate-return -Wno-multichar -Wnested-externs $NO_WARNINGS])
621
622 dnl define correct level for debugging messages
623 AG_GST_SET_LEVEL_DEFAULT($GST_GIT)
624
625 dnl *** finalize CFLAGS, LDFLAGS, LIBS
626
627 dnl Overview:
628 dnl GST_OPTION_CFLAGS:  common cflags for profiling, debugging, errors, ...
629 dnl GST_ALL_*:          vars shared by all built objects
630 dnl GST_LIB_LDFLAGS:    additional linker flags for all libaries
631 dnl GST_OBJ_*:          additional vars to link to the core library
632 dnl                     include GST_ALL_*
633 dnl GST_LT_LDFLAGS:     library versioning of our libraries
634 dnl GST_PLUGIN_LDFLAGS: flags to be used for all plugins
635
636 dnl GST_OPTION_CFLAGS
637 if test "x$USE_DEBUG" = xyes; then
638    PROFILE_CFLAGS="-g"
639 fi
640 AC_SUBST(PROFILE_CFLAGS)
641
642 # GST_DISABLE_DEPRECATED: hide the visibility of deprecated
643 # functionality from the API that gstreamer uses
644 # GST_REMOVE_DEPRECATED: don't compile deprecated functionality (breaks ABI)
645 if test "x$PACKAGE_VERSION_NANO" = "x1"; then
646   dnl Define _only_ when compiling from git (not for pre-releases or releases)
647   DEPRECATED_CFLAGS="-DGST_DISABLE_DEPRECATED"
648 else
649   DEPRECATED_CFLAGS=""
650 fi
651 AC_SUBST(DEPRECATED_CFLAGS)
652
653 dnl every flag in GST_OPTION_CFLAGS can be overridden at make time via e.g.
654 dnl make DEPRECATED_CFLAGS=''
655 GST_OPTION_CFLAGS="\$(WARNING_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
656 GST_OPTION_CXXFLAGS="\$(WARNING_CXXFLAGS) \$(ERROR_CXXFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
657 GST_OPTION_CFLAGS="$GST_OPTION_CFLAGS -DGST_USE_UNSTABLE_API"
658 GST_OPTION_CXXFLAGS="$GST_OPTION_CXXFLAGS -DGST_USE_UNSTABLE_API"
659 AC_SUBST(GST_OPTION_CFLAGS)
660 AC_SUBST(GST_OPTION_CXXFLAGS)
661
662 dnl GST_ALL_*
663 dnl vars common to for all internal objects (core libs, elements, applications)
664 dnl CFLAGS:
665 dnl - src and build dirs need to be added because every piece that gets built
666 dnl   will need the GStreamer source and generated headers
667 dnl LIBS: XML doesn't need to be added because we don't explicitly use symbols
668 dnl       from LibXML except for in the core library
669 GST_ALL_CXXFLAGS="-I\$(top_srcdir)/libs -I\$(top_srcdir) -I\$(top_builddir)/libs -I\$(top_builddir) $GLIB_CFLAGS \$(GLIB_EXTRA_CFLAGS) $XML_CFLAGS \$(GST_OPTION_CXXFLAGS) \$(ERROR_CXXFLAGS)"
670 GST_ALL_CFLAGS="-I\$(top_srcdir)/libs -I\$(top_srcdir) -I\$(top_builddir)/libs -I\$(top_builddir) $GLIB_CFLAGS \$(GLIB_EXTRA_CFLAGS) $XML_CFLAGS \$(GST_OPTION_CFLAGS) \$(ERROR_CFLAGS)"
671
672 dnl FIXME: check if LTLIBINTL is needed everywhere
673 dnl I presume it is given that it contains the symbols that _() stuff maps to
674 GST_ALL_LIBS="$GLIB_LIBS $LTLIBINTL \$(GCOV_LIBS)"
675
676 dnl LDFLAGS really should only contain flags, not libs - they get added before
677 dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
678 GST_ALL_LDFLAGS="-no-undefined"
679 if test "x${enable_Bsymbolic}" = "xyes"; then
680   GST_ALL_LDFLAGS="$GST_ALL_LDFLAGS -Wl,-Bsymbolic-functions"
681 fi
682
683 AC_SUBST(GST_ALL_CFLAGS)
684 AC_SUBST(GST_ALL_CXXFLAGS)
685 AC_SUBST(GST_ALL_LIBS)
686 AC_SUBST(GST_ALL_LDFLAGS)
687
688 dnl GST_LIB_LDFLAGS
689 dnl linker flags shared by all libraries
690 dnl LDFLAGS modifier defining exported symbols from built libraries
691 GST_LIB_LDFLAGS="-export-symbols-regex \^[_]?\(gst_\|Gst\|GST_\).*"
692 AC_SUBST(GST_LIB_LDFLAGS)
693
694 dnl GST_OBJ_*
695 dnl default vars for all internal objects built on libgstreamer
696 dnl includes GST_ALL_*
697 GST_OBJ_CFLAGS="\$(GST_ALL_CFLAGS)"
698 GST_OBJ_CXXFLAGS="\$(GST_ALL_CXXFLAGS)"
699 GST_OBJ_LIBS="\$(top_builddir)/gst/libgstreamer-$GST_MAJORMINOR.la \$(GST_ALL_LIBS)"
700 AC_SUBST(GST_OBJ_CFLAGS)
701 AC_SUBST(GST_OBJ_CXXFLAGS)
702 AC_SUBST(GST_OBJ_LIBS)
703
704 dnl GST_PLUGIN_LDFLAGS
705 dnl LDFLAGS for plugins; includes GST_ALL_LDFLAGS
706 GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^[_]*gst_plugin_desc.*' $GST_ALL_LDFLAGS"
707 AC_SUBST(GST_PLUGIN_LDFLAGS, "$GST_PLUGIN_LDFLAGS")
708
709 dnl plugin scanner locations
710 AS_AC_EXPAND(GST_PLUGIN_SCANNER_INSTALLED,${libexecdir}/gstreamer-$GST_MAJORMINOR/gst-plugin-scanner)
711 AC_DEFINE_UNQUOTED(GST_PLUGIN_SCANNER_INSTALLED,
712     "$GST_PLUGIN_SCANNER_INSTALLED", [location of the installed gst-plugin-scanner])
713 AC_SUBST(GST_PLUGIN_SCANNER_INSTALLED)
714
715 dnl things for our internal libcheck (must be called even if building
716 dnl libcheck is disabled because it defines conditionals)
717 AG_GST_CHECK_CHECKS()
718
719 AC_CONFIG_FILES(
720 Makefile
721 gst/Makefile
722 gst/gstconfig.h
723 gst/gstversion.h
724 gst/parse/Makefile
725 libs/Makefile
726 libs/gst/Makefile
727 libs/gst/base/Makefile
728 libs/gst/check/Makefile
729 libs/gst/check/libcheck/Makefile
730 libs/gst/check/libcheck/check.h
731 libs/gst/controller/Makefile
732 libs/gst/helpers/Makefile
733 libs/gst/net/Makefile
734 plugins/Makefile
735 plugins/elements/Makefile
736 po/Makefile.in
737 tests/Makefile
738 tests/benchmarks/Makefile
739 tests/check/Makefile
740 tests/misc/Makefile
741 tests/examples/Makefile
742 tests/examples/adapter/Makefile
743 tests/examples/controller/Makefile
744 tests/examples/stepping/Makefile
745 tests/examples/helloworld/Makefile
746 tests/examples/launch/Makefile
747 tests/examples/manual/Makefile
748 tests/examples/metadata/Makefile
749 tests/examples/queue/Makefile
750 tests/examples/streams/Makefile
751 tests/examples/typefind/Makefile
752 tools/Makefile
753 common/Makefile
754 common/m4/Makefile
755 docs/Makefile
756 docs/design/Makefile
757 docs/faq/Makefile
758 docs/gst/Makefile
759 docs/gst/gstreamer.types
760 docs/libs/Makefile
761 docs/plugins/Makefile
762 docs/manual/Makefile
763 docs/pwg/Makefile
764 docs/slides/Makefile
765 docs/xsl/Makefile
766 docs/version.entities
767 m4/Makefile
768 pkgconfig/Makefile
769 stamp.h
770 pkgconfig/gstreamer.pc
771 pkgconfig/gstreamer-uninstalled.pc
772 pkgconfig/gstreamer-base.pc
773 pkgconfig/gstreamer-base-uninstalled.pc
774 pkgconfig/gstreamer-check.pc
775 pkgconfig/gstreamer-check-uninstalled.pc
776 pkgconfig/gstreamer-controller.pc
777 pkgconfig/gstreamer-controller-uninstalled.pc
778 pkgconfig/gstreamer-net.pc
779 pkgconfig/gstreamer-net-uninstalled.pc
780 gst-element-check.m4
781 gstreamer.spec
782 )
783
784 dnl Create the config.h file for Visual Studio builds
785 dnl Beware of spaces and /'s in some of the shell variable contents.
786 sed \
787     -e 's/.*config.h.in.*autoheader.*/\/* Autogenerated config.h created for win32 Visual Studio builds *\/\n\n\/* PREFIX -- specifically added for Windows for easier moving *\/\n#define PREFIX "C:\\\\gstreamer"/' \
788     -e 's/.* GETTEXT_PACKAGE$/#define GETTEXT_PACKAGE "'$GETTEXT_PACKAGE'"/' \
789     -e 's/.* GST_DATADIR$/#define GST_DATADIR PREFIX "\\\\share"/' \
790     -e 's/.* GST_LEVEL_DEFAULT$/#define GST_LEVEL_DEFAULT GST_LEVEL_ERROR/' \
791     -e 's/.* GST_LICENSE$/#define GST_LICENSE "'$GST_LICENSE'"/' \
792     -e 's/.* GST_MAJORMINOR$/#define GST_MAJORMINOR "'$GST_MAJORMINOR'"/' \
793     -e "s,.* GST_PACKAGE_NAME$,#define GST_PACKAGE_NAME \"${GST_PACKAGE_NAME}\"," \
794     -e 's/.* GST_PACKAGE_ORIGIN$/#define GST_PACKAGE_ORIGIN "Unknown package origin"/' \
795     -e "s,.* GST_PACKAGE_RELEASE_DATETIME$,#define GST_PACKAGE_RELEASE_DATETIME \"${GST_PACKAGE_RELEASE_DATETIME}\"," \
796     -e 's/.* HAVE_CPU_I386$/#define HAVE_CPU_I386 1/' \
797     -e 's/.* HAVE_FGETPOS$/#define HAVE_FGETPOS 1/' \
798     -e 's/.* HAVE_FSETPOS$/#define HAVE_FSETPOS 1/' \
799     -e 's/.* HAVE_PROCESS_H$/#define HAVE_PROCESS_H 1/' \
800     -e 's/.* HAVE_STDLIB_H$/#define HAVE_STDLIB_H 1/' \
801     -e 's/.* HAVE_STRING_H$/#define HAVE_STRING_H 1/' \
802     -e 's/.* HAVE_SYS_STAT_H$/#define HAVE_SYS_STAT_H 1/' \
803     -e 's/.* HAVE_SYS_TYPES_H$/#define HAVE_SYS_TYPES_H 1/' \
804     -e 's/.* HAVE_WIN32$/#define HAVE_WIN32 1/' \
805     -e 's/.* HAVE_WINSOCK2_H$/#define HAVE_WINSOCK2_H 1/' \
806     -e 's/.* HOST_CPU$/#define HOST_CPU "i686"/' \
807     -e 's/.* MEMORY_ALIGNMENT_MALLOC/#define MEMORY_ALIGNMENT_MALLOC 1/' \
808     -e 's/.* LIBDIR$/#ifdef _DEBUG\n#  define LIBDIR PREFIX "\\\\debug\\\\lib"\n#else\n#  define LIBDIR PREFIX "\\\\lib"\n#endif/' \
809     -e 's/.* LOCALEDIR$/#define LOCALEDIR PREFIX "\\\\share\\\\locale"/' \
810     -e 's/.* PACKAGE$/#define PACKAGE "gstreamer"/' \
811     -e 's/.* PACKAGE_BUGREPORT$/#define PACKAGE_BUGREPORT "http:\/\/bugzilla.gnome.org\/enter_bug.cgi?product=GStreamer"/' \
812     -e 's/.* PACKAGE_NAME$/#define PACKAGE_NAME "'$PACKAGE_NAME'"/' \
813     -e "s/.* PACKAGE_STRING$/#define PACKAGE_STRING \"$PACKAGE_STRING\"/" \
814     -e 's/.* PACKAGE_TARNAME$/#define PACKAGE_TARNAME "'$PACKAGE_TARNAME'"/' \
815     -e 's/.* PACKAGE_VERSION$/#define PACKAGE_VERSION "'$PACKAGE_VERSION'"/' \
816     -e 's/.* PLUGINDIR$/#ifdef _DEBUG\n#  define PLUGINDIR PREFIX "\\\\debug\\\\lib\\\\gstreamer-0.11"\n#else\n#  define PLUGINDIR PREFIX "\\\\lib\\\\gstreamer-0.11"\n#endif/' \
817     -e 's/.* GST_PLUGIN_SCANNER_INSTALLED$/#define GST_PLUGIN_SCANNER_INSTALLED LIBDIR "\\\\gst-plugin-scanner"/' \
818     -e 's/.* VERSION$/#define VERSION "'$VERSION'"/' \
819     config.h.in >win32/common/config.h-new
820
821 AC_OUTPUT
822
823 dnl negate for output
824 if test "x${GST_DISABLE_GST_DEBUG}" = "xno"; then enable_gst_debug="yes"; fi
825 if test "x${GST_DISABLE_PARSE}" = "xno"; then enable_parse="yes"; fi
826 if test "x${GST_DISABLE_OPTION_PARSING}" = "xno"; then enable_option_parsing="yes"; fi
827 if test "x${GST_DISABLE_TRACE}" = "xno"; then enable_trace="yes"; fi
828 if test "x${GST_DISABLE_ALLOC_TRACE}" = "xno"; then enable_alloc_trace="yes"; fi
829 if test "x${GST_DISABLE_PLUGIN}" = "xno"; then enable_plugin="yes"; fi
830 if test "x${GST_DISABLE_REGISTRY}" = "xno"; then enable_registry="yes"; fi
831 if test "x${GST_DISABLE_NET}" = "xno"; then enable_net="yes"; fi
832
833 echo "
834
835 Configuration
836         Version                    : ${VERSION}
837         Source code location       : ${srcdir}
838         Prefix                     : ${prefix}
839         Compiler                   : ${CC}
840         Package name               : ${GST_PACKAGE_NAME}
841         Package origin             : ${GST_PACKAGE_ORIGIN}
842
843         Documentation (manuals)    : ${enable_docbook}
844         Documentation (API)        : ${enable_gtk_doc}
845
846         Debug Logging              : ${enable_gst_debug}
847         Command-line parser        : ${enable_parse}
848         Option parsing in gst_init : ${enable_option_parsing}
849         Tracing subsystem          : ${enable_trace}
850         Allocation tracing         : ${enable_alloc_trace}
851         Plugin registry            : ${enable_registry}
852         Plugin support             : ${enable_plugin}
853         Network support            : ${enable_net}
854         Unit testing support       : ${BUILD_CHECK}
855
856         Debug                      : ${USE_DEBUG}
857         Profiling                  : ${USE_PROFILING}
858
859         Building examples          : ${BUILD_EXAMPLES}
860         Building test apps         : ${BUILD_TESTS}
861         Building tests that fail   : ${BUILD_FAILING_TESTS}
862 "