upload tizen1.0 source
[framework/multimedia/gstreamer0.10-ffmpeg.git] / common / m4 / gst-function.m4
1 dnl
2 dnl Check for compiler mechanism to show functions in debugging
3 dnl copied from an Ali patch floating on the internet
4 dnl
5 AC_DEFUN([AG_GST_CHECK_FUNCTION],[
6   dnl #1: __PRETTY_FUNCTION__
7   AC_MSG_CHECKING(whether $CC implements __PRETTY_FUNCTION__)
8   AC_CACHE_VAL(gst_cv_have_pretty_function,[
9     AC_TRY_LINK([#include <stdio.h>],
10                 [printf("%s", __PRETTY_FUNCTION__);],
11                 gst_cv_have_pretty_function=yes,
12                 gst_cv_have_pretty_function=no)
13   ])
14   AC_MSG_RESULT($gst_cv_have_pretty_function)
15   if test "$gst_cv_have_pretty_function" = yes; then
16     AC_DEFINE(HAVE_PRETTY_FUNCTION, 1,
17               [defined if the compiler implements __PRETTY_FUNCTION__])
18   fi
19
20 dnl #2: __FUNCTION__
21   AC_MSG_CHECKING(whether $CC implements __FUNCTION__)
22   AC_CACHE_VAL(gst_cv_have_function,[
23     AC_TRY_LINK([#include <stdio.h>],
24                 [printf("%s", __FUNCTION__);],
25                 gst_cv_have_function=yes,
26                 gst_cv_have_function=no)
27   ])
28   AC_MSG_RESULT($gst_cv_have_function)
29   if test "$gst_cv_have_function" = yes; then
30     AC_DEFINE(HAVE_FUNCTION, 1,
31               [defined if the compiler implements __FUNCTION__])
32   fi
33
34 dnl #3: __func__
35   AC_MSG_CHECKING(whether $CC implements __func__)
36   AC_CACHE_VAL(gst_cv_have_func,[
37     AC_TRY_LINK([#include <stdio.h>],
38                 [printf("%s", __func__);],
39                 gst_cv_have_func=yes,
40                 gst_cv_have_func=no)
41   ])
42   AC_MSG_RESULT($gst_cv_have_func)
43   if test "$gst_cv_have_func" = yes; then
44     AC_DEFINE(HAVE_FUNC, 1,
45               [defined if the compiler implements __func__])
46   fi
47
48 dnl now define FUNCTION to whatever works, and fallback to ""
49   if test "$gst_cv_have_pretty_function" = yes; then
50     function=__PRETTY_FUNCTION__
51   else
52     if test "$gst_cv_have_function" = yes; then
53       function=__FUNCTION__
54     else
55       if test "$gst_cv_have_func" = yes; then
56         function=__func__
57       else
58         function=\"\"
59       fi
60     fi
61   fi
62   AC_DEFINE_UNQUOTED(GST_FUNCTION, $function, [macro to use to show function name])
63 ])